ZQuest Classic Coverage Report


Directory: src/
File: src/zc/hero.cpp
Date: 2025-08-24 12:35:46
Exec Total Coverage
Lines: 15800 21544 73.3%
Functions: 421 503 83.7%
Branches: 13887 23939 58.0%

Line Branch Exec Source
1 #include "base/general.h"
2 #include "base/handles.h"
3 #include "base/mapscr.h"
4 #include "base/util.h"
5 #include "base/zdefs.h"
6 #include "zc/maps.h"
7 #include "zc/replay.h"
8 #include "zc/zelda.h"
9
10 #include <optional>
11 #include <cstring>
12 #include <set>
13 #include <stdio.h>
14
15 #include "base/qrs.h"
16 #include "base/dmap.h"
17 #include "zc/hero.h"
18 #include "zc/guys.h"
19 #include "subscr.h"
20 #include "zc/maps.h"
21 #include "zc/replay.h"
22 #include "zc/zc_ffc.h"
23 #include "zc/zc_subscr.h"
24 #include "zc/decorations.h"
25 #include "gamedata.h"
26 #include "hero_tiles.h"
27 #include "zc/title.h"
28 #include "zc/ffscript.h"
29 #include "drawing.h"
30 #include "zc/combos.h"
31 #include "base/zc_math.h"
32 #include "user_object.h"
33 #include "slopes.h"
34 #include "zc/zc_sys.h"
35 #include "zinfo.h"
36 #include "base/misctypes.h"
37 #include "music_playback.h"
38 #include "iter.h"
39
40 extern refInfo playerScriptData;
41 #include "zscriptversion.h"
42 #include "particles.h"
43 #include <fmt/format.h>
44 #include "zc/render.h"
45 #include <array>
46
47 extern refInfo *ri; //= NULL;
48 extern int32_t(*stack)[MAX_STACK_SIZE];
49 extern portal mirror_portal;
50 using std::set;
51
52 extern int32_t skipcont;
53
54 extern int32_t draw_screen_clip_rect_x1;
55 extern int32_t draw_screen_clip_rect_x2;
56 extern int32_t draw_screen_clip_rect_y1;
57 extern int32_t draw_screen_clip_rect_y2;
58
59 int32_t hero_count = -1;
60 extern int32_t hero_animation_speed; //lower is faster animation
61 static int32_t z3step = 2;
62 412 static zfix hero_newstep(1.5);
63 412 static zfix hero_newstep_diag(1.5);
64 bool did_scripta=false;
65 bool did_scriptb=false;
66 bool did_scriptl=false;
67 byte lshift = 0;
68 int32_t dowpn = -1;
69 int32_t directItemA = -1;
70 int32_t directItemB = -1;
71 int32_t directItemX = -1;
72 int32_t directItemY = -1;
73 int32_t directWpn = -1;
74 int32_t whistleitem=-1;
75 extern int32_t script_hero_cset;
76
77 void playLevelMusic();
78
79 byte lsteps[8] = { 1, 1, 2, 1, 1, 2, 1, 1 };
80
81 #define CANFORCEFACEUP (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0 && dir!=up && (action==walking || action==none))
82 #define NO_GRIDLOCK (get_qr(qr_DISABLE_4WAY_GRIDLOCK)||get_qr(qr_NEW_HERO_MOVEMENT2))
83 #define STANDING_Z_STATE (standing_on_z<0?standing_on_z:(standing_on_z+z+fakez < 0 ? zslongToFix(2147483647) : standing_on_z+z+fakez))
84 #define FIXED_Z3_ANIMATION ((zinit.heroAnimationStyle==las_zelda3||zinit.heroAnimationStyle==las_zelda3slow)&&!get_qr(qr_BROKEN_Z3_ANIMATION))
85
86 47 bool item_error()
87 {
88
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 39 times.
47 if(QMisc.miscsfx[sfxERROR])
89 8 sfx(QMisc.miscsfx[sfxERROR]);
90 47 return false;
91 }
92 5458408 static inline bool on_sideview_slope(int32_t x, int32_t y, int32_t oldx, int32_t oldy)
93 {
94
2/2
✓ Branch 0 taken 811 times.
✓ Branch 1 taken 5457597 times.
5458408 if(check_new_slope(x, y+0.0001_zf, 16, 16, oldx, oldy, false, true) < 0) return true;
95 5457597 return false;
96 5458408 }
97
98 12399079 static inline bool platform_fallthrough(bool doslopecheck = true)
99 {
100
2/2
✓ Branch 0 taken 10579123 times.
✓ Branch 1 taken 1819956 times.
12399079 if (!getInput(btnDown, INPUT_HERO_ACTION | (get_qr(qr_SIDEVIEW_FALLTHROUGH_USES_DRUNK) ? INPUT_DRUNK : 0)))
101 10579123 return false;
102
103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819956 times.
1819956 if (get_qr(qr_DOWN_FALL_THROUGH_SIDEVIEW_PLATFORMS))
104 return true;
105
106
3/4
✓ Branch 0 taken 33989 times.
✓ Branch 1 taken 1785967 times.
✓ Branch 2 taken 33989 times.
✗ Branch 3 not taken.
1819956 if (Hero.jumping < 0 && get_qr(qr_DOWNJUMP_FALL_THROUGH_SIDEVIEW_PLATFORMS))
107 return true;
108
109
7/8
✓ Branch 0 taken 1819956 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 706 times.
✓ Branch 3 taken 1819250 times.
✓ Branch 4 taken 1819202 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 105 times.
✓ Branch 7 taken 1819851 times.
3639206 if (doslopecheck && !on_sideview_slope(Hero.x, Hero.y,Hero.old_x,Hero.old_y) && (on_sideview_slope(Hero.x,Hero.y+1,Hero.old_x,Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)))
110 105 return true;
111
112 1819851 return false;
113 12399079 }
114
115 5497 static inline bool on_sideview_solid(zfix x, zfix y, bool ignoreFallthrough = false, int32_t slopesmisc = 0)
116 {
117
3/4
✓ Branch 0 taken 5497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4451 times.
✓ Branch 3 taken 1046 times.
5497 if(slopesmisc != 1 && check_slope(x, y + 0.0001_zf, 16, 16, (slopesmisc == 3), true) < 0) return true;
118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4451 times.
4451 if(slopesmisc == 2) return false;
119
4/4
✓ Branch 0 taken 3579 times.
✓ Branch 1 taken 872 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 3569 times.
4451 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)) return true;
120 3569 mapscr* s = get_scr_for_world_xy(x, y);
121
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3569 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3569 if (y>=world_h-16 && cur_screen>=0x70 && !(s->flags2&wfDOWN)) return true;
122
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3569 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3569 if (platform_fallthrough() && !ignoreFallthrough) return false;
123
2/4
✓ Branch 0 taken 3569 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3569 times.
✗ Branch 3 not taken.
3569 if(slopesmisc != 1 && check_slope(x, y + 0.0001_zf, 16, 16, false, true) < 0) return true;
124
6/6
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 61 times.
✓ Branch 3 taken 243 times.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 3508 times.
3873 if (y.getInt() % 16 ==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
125 61 return true;
126 3508 return false;
127 5497 }
128
129 16694759 static inline bool on_sideview_solid_oldpos(sprite* obj, bool ignoreFallthrough = false, int32_t slopesmisc = 0, zfix xofs = 0, zfix yofs = 0)
130 {
131 16694759 zfix rx = obj->x+obj->hxofs+obj->sxofs+xofs, ry = obj->y+obj->hyofs+obj->syofs+yofs,
132 16694759 rw = obj->hit_width+obj->sxsz_ofs, rh = obj->hit_height+obj->sysz_ofs,
133 16694759 orx = obj->old_x+obj->hxofs+obj->sxofs, ory = obj->old_y+obj->hyofs+obj->syofs,
134 16694759 x = obj->x+xofs, y = obj->y+yofs;
135
4/4
✓ Branch 0 taken 2065998 times.
✓ Branch 1 taken 14628761 times.
✓ Branch 2 taken 2052634 times.
✓ Branch 3 taken 13364 times.
16694759 if(slopesmisc != 1 && check_new_slope(rx, ry+0.0001_zf, rw, rh, orx, ory, (slopesmisc == 3), true, obj->slopeid) < 0)
136 13364 return true;
137
2/2
✓ Branch 0 taken 158055 times.
✓ Branch 1 taken 16523340 times.
16681395 if(slopesmisc == 2)
138 158055 return false;
139
4/4
✓ Branch 0 taken 12734380 times.
✓ Branch 1 taken 3788960 times.
✓ Branch 2 taken 337926 times.
✓ Branch 3 taken 12396454 times.
16523340 if (_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1))
140 4126886 return true;
141
6/6
✓ Branch 0 taken 103114 times.
✓ Branch 1 taken 12293340 times.
✓ Branch 2 taken 6150 times.
✓ Branch 3 taken 96964 times.
✓ Branch 4 taken 5206 times.
✓ Branch 5 taken 944 times.
12396454 if (y>=world_h-16 && cur_screen>=0x70 && !(hero_scr->flags2&wfDOWN))
142 944 return true;
143
3/4
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 12395405 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 105 times.
12395510 if (platform_fallthrough() && !ignoreFallthrough) return false;
144
3/4
✓ Branch 0 taken 878415 times.
✓ Branch 1 taken 11516990 times.
✓ Branch 2 taken 878415 times.
✗ Branch 3 not taken.
12395405 if (slopesmisc != 1 && check_new_slope(rx, ry+0.0001_zf, rw, rh, orx, ory, false, true, obj->slopeid) < 0)
145 return true;
146
6/6
✓ Branch 0 taken 9279794 times.
✓ Branch 1 taken 3115611 times.
✓ Branch 2 taken 885 times.
✓ Branch 3 taken 3114726 times.
✓ Branch 4 taken 885 times.
✓ Branch 5 taken 12394520 times.
15511016 if (y.getInt()%16==0 && (checkSVLadderPlatform(x+4,y+16) || checkSVLadderPlatform(x+12,y+16)))
147 885 return true;
148 12394520 return false;
149 16694759 }
150
151 103022 static inline bool no_plat_action()
152 {
153
5/8
✓ Branch 0 taken 103022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102724 times.
✓ Branch 3 taken 298 times.
✓ Branch 4 taken 102724 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 102724 times.
103022 if(Hero.fallclk || Hero.drownclk || toogam || Hero.getOnSideviewLadder())
154 298 return true;
155
2/2
✓ Branch 0 taken 441 times.
✓ Branch 1 taken 102283 times.
102724 switch(Hero.action)
156 {
157 case freeze: case rafting: case inwind: case scrolling: case won: case hopping:
158 case climbcovertop: case climbcoverbottom: case dying: case drowning:
159 case falling: case lavadrowning: case sideswimfreeze: case sidedrowning:
160 441 return true;
161 }
162 102283 return false;
163 103022 }
164 84940 bool HeroClass::on_ffc_platform(ffcdata const& ffc, bool old)
165 {
166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84940 times.
84940 if(no_plat_action())
167 return false;
168
2/2
✓ Branch 0 taken 45120 times.
✓ Branch 1 taken 39820 times.
84940 if(!get_qr(qr_MULTI_PLATFORM_FFC))
169 {
170
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 39820 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
39820 if(platform_ffc && &ffc != platform_ffc)
171 return false;
172 39820 platform_ffc = nullptr;
173 39820 }
174
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84940 times.
84940 if(sideview_mode())
175 {
176 if((ffc.flags & (ffc_solid|ffc_platform|ffc_changer)) != (ffc_solid|ffc_platform))
177 return false;
178 zfix fx = old ? ffc.old_x : ffc.x, fy = old ? ffc.old_y : ffc.y;
179 static const zfix tol = 0.5_zf;
180 if((y+16-fy).getAbs() > tol)
181 return false;
182 if(fx > x+12)
183 return false;
184 if(fx+ffc.hit_width <= x+4)
185 return false;
186 }
187 else
188 {
189
2/2
✓ Branch 0 taken 84760 times.
✓ Branch 1 taken 180 times.
84940 if((ffc.flags & (ffc_platform|ffc_changer)) != ffc_platform)
190 84760 return false;
191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
180 if(z)
192 return false;
193 static const int tol = 3;
194
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 180 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 180 times.
180 if(!(old
195 180 ? ffc.collide_old(x + 8-tol, y + (bigHitbox ? 8 : 12), tol*2, tol*2)
196 : ffc.collide(x + 8-tol, y + (bigHitbox ? 8 : 12)-tol, tol*2, tol*2)))
197 180 return false;
198 }
199 platform_ffc = &ffc;
200 return true;
201 84940 }
202 18082 bool HeroClass::on_ffc_platform()
203 {
204
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 17343 times.
18082 if(no_plat_action())
205 739 return false;
206
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17343 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17343 if(platform_ffc && on_ffc_platform(*platform_ffc,false))
207 return true;
208 119446 bool any_on_platform = find_ffc([&](const ffc_handle_t& ffc_handle) {
209 84760 return on_ffc_platform(*ffc_handle.ffc, false);
210 17343 }).has_value();
211 17343 return any_on_platform;
212 18082 }
213
214 14773160 void HeroClass::check_platform_ffc()
215 {
216
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14773160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14773160 if(platform_ffc && !on_ffc_platform(*platform_ffc,false))
217 {
218 clear_platform_ffc();
219 on_ffc_platform();
220 }
221 14773160 }
222 37403 void HeroClass::clear_platform_ffc()
223 {
224 37403 platform_ffc = nullptr;
225 37403 }
226
227 2302 void HeroClass::snap_platform()
228 {
229
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 1292 times.
2302 if(check_new_slope(x, y+1, 16, 16, old_x, old_y, false, true) < 0)
230 1010 return;
231
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1292 if (y>=world_h-16 && cur_screen>=0x70 && !(hero_scr->flags2&wfDOWN))
232 {
233 y = world_h-16;
234 return;
235 }
236
4/4
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 887 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 385 times.
1292 if (!(_walkflag(x+4,y+16,1) || _walkflag(x+12,y+16,1)))
237 385 return;
238 907 movexy(0,1,false,true,false,false);
239 2302 }
240
241 41174805 bool usingActiveShield(int32_t itmid)
242 {
243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41174805 times.
41174805 if(Hero.shieldjinxclk) return false;
244
2/2
✓ Branch 0 taken 35562834 times.
✓ Branch 1 taken 5611971 times.
41174805 switch(Hero.action) //filter allowed actions
245 {
246 case none: case walking: case rafting:
247 case gothit: case swimhit:
248 35562834 break;
249 5611971 default: return false;
250 }
251
4/4
✓ Branch 0 taken 12334 times.
✓ Branch 1 taken 35550500 times.
✓ Branch 2 taken 4320 times.
✓ Branch 3 taken 8014 times.
35562834 if(Hero.lift_wpn && (Hero.liftflags&LIFTFL_DIS_SHIELD)) return false;
252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35554820 times.
35554820 if(itmid < 0)
253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35554820 times.
35554820 itmid = (Hero.active_shield_id < 0
254 35554820 ? current_item_id(itype_shield,true,true) : Hero.active_shield_id);
255
2/2
✓ Branch 0 taken 31306883 times.
✓ Branch 1 taken 4247937 times.
35554820 if(itmid < 0) return false;
256
2/4
✓ Branch 0 taken 31306883 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31306883 times.
✗ Branch 3 not taken.
31306883 if (Hero.active_shield_id != itmid && Hero.on_cooldown(itmid)) return false;
257 31306883 auto const& itm = itemsbuf[itmid];
258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31306883 times.
31306883 if(item_disabled(itmid)) return false;
259
1/2
✓ Branch 0 taken 31306883 times.
✗ Branch 1 not taken.
31306883 if(!checkitem_jinx(itmid)) return false;
260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31306883 times.
31306883 if(!(itm.flags & item_flag9)) return false;
261 if(!isItmPressed(itmid))
262 {
263 byte intbtn = byte(itm.misc5&0xFF);
264 if(!itm.misc5 || !getIntBtnInput(intbtn, INPUT_DRUNK | INPUT_PEEK))
265 return false;
266 }
267 return (checkbunny(itmid) && checkmagiccost(itmid));
268 41174805 }
269 4447057 int32_t getCurrentShield(bool requireActive)
270 {
271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4447057 times.
4447057 if(Hero.shieldjinxclk) return -1;
272
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4447057 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4447057 if(Hero.active_shield_id > -1 && usingActiveShield(Hero.active_shield_id))
273 return Hero.active_shield_id;
274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4447057 times.
4447057 if(!requireActive) return current_item_id(itype_shield,false,true);
275 return -1;
276 4447057 }
277 625298 int32_t getCurrentActiveShield()
278 {
279 625298 int32_t id = Hero.active_shield_id;
280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 625298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
625298 if(id > -1 && usingActiveShield(id))
281 return id;
282 625298 return -1;
283 625298 }
284 14307785 int32_t refreshActiveShield()
285 {
286 14307785 int32_t id = -1;
287
2/2
✓ Branch 0 taken 14015061 times.
✓ Branch 1 taken 292724 times.
14307785 if (getInput(btnB, INPUT_DRUNK | INPUT_HERO_ACTION))
288 {
289
2/2
✓ Branch 0 taken 290821 times.
✓ Branch 1 taken 1903 times.
292724 itemdata const& dat = itemsbuf[NEG_OR_MASK(Bwpn, 0xFFF)];
290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292724 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292724 if (dat.type == itype_shield && (dat.flags & item_flag9))
291 {
292 id = NEG_OR_MASK(Bwpn, 0xFFF);
293 }
294 292724 }
295
3/4
✓ Branch 0 taken 14307785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13066128 times.
✓ Branch 3 taken 1241657 times.
14307785 if (id < 0 && getInput(btnA, INPUT_DRUNK | INPUT_HERO_ACTION))
296 {
297
2/2
✓ Branch 0 taken 1100142 times.
✓ Branch 1 taken 141515 times.
1241657 itemdata const& dat = itemsbuf[NEG_OR_MASK(Awpn, 0xFFF)];
298
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1241657 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1241657 if (dat.type == itype_shield && (dat.flags & item_flag9))
299 {
300 id = NEG_OR_MASK(Awpn, 0xFFF);
301 }
302 1241657 }
303
3/4
✓ Branch 0 taken 14307785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14295178 times.
✓ Branch 3 taken 12607 times.
14307785 if (id < 0 && getInput(btnEx1, INPUT_DRUNK | INPUT_HERO_ACTION))
304 {
305
2/2
✓ Branch 0 taken 2047 times.
✓ Branch 1 taken 10560 times.
12607 itemdata const& dat = itemsbuf[NEG_OR_MASK(Xwpn, 0xFFF)];
306
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12607 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12607 if (dat.type == itype_shield && (dat.flags & item_flag9))
307 {
308 id = NEG_OR_MASK(Xwpn, 0xFFF);
309 }
310 12607 }
311
3/4
✓ Branch 0 taken 14307785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14305066 times.
✓ Branch 3 taken 2719 times.
14307785 if (id < 0 && getInput(btnEx2, INPUT_DRUNK | INPUT_HERO_ACTION))
312 {
313
2/2
✓ Branch 0 taken 2483 times.
✓ Branch 1 taken 236 times.
2719 itemdata const& dat = itemsbuf[NEG_OR_MASK(Ywpn, 0xFFF)];
314
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2719 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2719 if (dat.type == itype_shield && (dat.flags & item_flag9))
315 {
316 id = NEG_OR_MASK(Ywpn, 0xFFF);
317 }
318 2719 }
319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14307785 times.
14307785 if (id < 0)
320 {
321 14307785 auto shield_id = current_item_id(itype_shield, false, true);
322 14307785 itemdata const& dat = itemsbuf[shield_id];
323
3/4
✓ Branch 0 taken 12688593 times.
✓ Branch 1 taken 1619192 times.
✓ Branch 2 taken 12688593 times.
✗ Branch 3 not taken.
14307785 if (dat.type == itype_shield && (dat.flags & item_flag9))
324 {
325 byte intbtn = byte(dat.misc5 & 0xFF);
326 if (getIntBtnInput(intbtn, INPUT_DRUNK | INPUT_PEEK))
327 id = shield_id;
328 }
329 14307785 }
330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14307785 times.
14307785 if(!usingActiveShield(id))
331 14307785 return -1;
332 return id;
333 14307785 }
334 static bool is_immobile()
335 {
336 if(!get_qr(qr_NEW_HERO_MOVEMENT))
337 return false;
338 zfix rate(Hero.steprate);
339 int32_t shieldid = getCurrentActiveShield();
340 if(shieldid > -1)
341 {
342 itemdata const& shield = itemsbuf[shieldid];
343 if(shield.flags & item_flag10) //Change Speed flag
344 {
345 zfix perc = shield.misc7;
346 perc /= 100;
347 if(perc < 0)
348 perc = (perc*-1)+1;
349 rate = (rate * perc) + shield.misc8;
350 }
351 }
352 return rate != 0;
353 }
354
355 28817080 bool nomove_action(int action)
356 {
357
2/2
✓ Branch 0 taken 27601637 times.
✓ Branch 1 taken 1215443 times.
28817080 switch(action)
358 {
359 case gothit:
360 case drowning:
361 case lavadrowning:
362 case sidedrowning:
363 case falling:
364 case freeze:
365 case sideswimfreeze:
366 case scrolling:
367 case casting:
368 case sideswimcasting:
369 case landhold1:
370 case landhold2:
371 case waterhold1:
372 case waterhold2:
373 case sidewaterhold1:
374 case sidewaterhold2:
375 case hopping:
376 case inwind:
377 1215443 return true;
378 }
379 27601637 return false;
380 28817080 }
381
382 14701815 bool HeroClass::isStanding(bool forJump)
383 {
384
3/4
✓ Branch 0 taken 14669984 times.
✓ Branch 1 taken 31831 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14669984 times.
14701815 if(z || fakez) return false;
385
4/4
✓ Branch 0 taken 332206 times.
✓ Branch 1 taken 14337778 times.
✓ Branch 2 taken 4782 times.
✓ Branch 3 taken 161022 times.
14835788 if(isSideViewHero() && !on_sideview_solid_oldpos(this)
386
4/6
✓ Branch 0 taken 165804 times.
✓ Branch 1 taken 166402 times.
✓ Branch 2 taken 165804 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 165804 times.
✗ Branch 5 not taken.
332206 && !ladderx && !laddery && !getOnSideviewLadder())
387 161022 return false;
388
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 14508926 times.
14508962 if(hoverclk) return false;
389
2/2
✓ Branch 0 taken 605130 times.
✓ Branch 1 taken 13903796 times.
14508926 if(nomove_action(action)) return false;
390 13903796 int32_t val = check_pitslide();
391
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 13903761 times.
13903796 if(val == -2) return false;
392
2/2
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 13903504 times.
13903761 if(val == -1) return true;
393 257 return forJump;
394 14701815 }
395 830313 bool HeroClass::isLifting()
396 {
397
2/2
✓ Branch 0 taken 11209 times.
✓ Branch 1 taken 819104 times.
830313 if(lift_wpn) return true;
398 819104 return false;
399 830313 }
400 62 void HeroClass::set_liftflags(int liftid)
401 {
402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(unsigned(liftid) >= MAXITEMS)
403 return;
404 62 itemdata const& itm = itemsbuf[liftid];
405
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 SETFLAG(liftflags, LIFTFL_DIS_SWIMMING, !(itm.flags & item_flag2));
406
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39 times.
62 SETFLAG(liftflags, LIFTFL_DIS_SHIELD, itm.flags & item_flag3);
407
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 39 times.
62 SETFLAG(liftflags, LIFTFL_DIS_ITEMS, itm.flags & item_flag4);
408
1/2
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
62 SETFLAG(liftflags, LIFTFL_DROP_ON_HIT, itm.flags & item_flag5);
409 62 }
410
411 43723630 int32_t get_grav_boots_id()
412 {
413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43723630 times.
43723630 if (Hero.last_grav_boots_id > -1)
414 return Hero.last_grav_boots_id;;
415 int32_t grav_id;
416
2/2
✓ Branch 0 taken 42711946 times.
✓ Branch 1 taken 1011684 times.
43723630 if (Hero.sideview_mode())
417 {
418
2/2
✓ Branch 0 taken 965736 times.
✓ Branch 1 taken 45948 times.
1011684 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
419 {
420
1/2
✓ Branch 0 taken 45948 times.
✗ Branch 1 not taken.
45948 if ((grav_id = current_item_id(itype_gravity_down_boots, true)) >= 0)
421 if (checkmagiccost(grav_id) && checkbunny(grav_id))
422 return (Hero.last_grav_boots_id = grav_id);
423 45948 }
424
2/2
✓ Branch 0 taken 925064 times.
✓ Branch 1 taken 86620 times.
1011684 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION))
425 {
426
1/2
✓ Branch 0 taken 86620 times.
✗ Branch 1 not taken.
86620 if ((grav_id = current_item_id(itype_gravity_up_boots, true)) >= 0)
427 if (checkmagiccost(grav_id) && checkbunny(grav_id))
428 return (Hero.last_grav_boots_id = grav_id);
429 86620 }
430 1011684 }
431
1/2
✓ Branch 0 taken 43723630 times.
✗ Branch 1 not taken.
43723630 if ((grav_id = current_item_id(itype_gravity_boots, true)) >= 0)
432 if (checkmagiccost(grav_id) && checkbunny(grav_id))
433 if (!(itemsbuf[grav_id].flags & item_flag1) || Hero.sideview_mode()) // sideview-only boots only work in sideview
434 return (Hero.last_grav_boots_id = grav_id);
435 43723630 return -1;
436 43723630 }
437 29414222 int32_t HeroClass::get_gravity(bool skip_custom) const
438 {
439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29414222 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29414222 if (custom_gravity && !skip_custom)
440 return custom_gravity.getZLong();
441
2/2
✓ Branch 0 taken 29402890 times.
✓ Branch 1 taken 11332 times.
29414222 if (last_rocs_id != -1)
442 {
443 11332 itemdata const& itm = itemsbuf[last_rocs_id];
444
1/2
✓ Branch 0 taken 11332 times.
✗ Branch 1 not taken.
11332 if (itm.flags & item_flag2)
445 {
446 if ((!(itm.flags & item_flag3) || fall < 0) &&
447 (!(itm.flags & item_flag4) || fall > 0))
448 return itm.misc3 * 100;
449 }
450 11332 }
451 29414222 int32_t grav_id = get_grav_boots_id();
452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29414222 times.
29414222 if (grav_id > -1)
453 return itemsbuf[grav_id].misc1;
454 29414222 return sprite::get_gravity(skip_custom);
455 29414222 }
456 14309408 int32_t HeroClass::get_terminalv(bool skip_custom) const
457 {
458
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14309408 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14309408 if (custom_terminal_v && !skip_custom)
459 return custom_terminal_v.getZLong() / 100;
460
2/2
✓ Branch 0 taken 14303831 times.
✓ Branch 1 taken 5577 times.
14309408 if (last_rocs_id != -1)
461 {
462 5577 itemdata const& itm = itemsbuf[last_rocs_id];
463
1/2
✓ Branch 0 taken 5577 times.
✗ Branch 1 not taken.
5577 if (itm.flags & item_flag5)
464 return itm.misc4;
465 5577 }
466 14309408 int32_t grav_id = get_grav_boots_id();
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14309408 times.
14309408 if (grav_id >= 0)
468 return itemsbuf[grav_id].misc2 / 100;
469 14309408 return sprite::get_terminalv(skip_custom);
470 14309408 }
471
472 14309416 void HeroClass::update_current_screen()
473 {
474 14309416 int cx = x + 8, cy = y + 8;
475
2/2
✓ Branch 0 taken 41833 times.
✓ Branch 1 taken 14267583 times.
14309416 if (replay_version_check(0, 43)) // hero_screen previously used top-left, not center
476 {
477 14267583 cx = x;
478 14267583 cy = y;
479 14267583 }
480
481 14309416 int scr_x = vbound(cx, 0, world_w - 1) / 256;
482 14309416 int scr_y = vbound(cy, 0, world_h - 1) / 176;
483 14309416 int new_screen = cur_screen + scr_x + scr_y * 16;
484
2/2
✓ Branch 0 taken 14301654 times.
✓ Branch 1 taken 7762 times.
14309416 if (maze_state.active == 1)
485 7762 new_screen = maze_state.scr->screen;
486
7/12
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 14309200 times.
✓ Branch 2 taken 216 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 216 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 216 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 216 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 216 times.
14309416 if (current_screen != new_screen && scr_x >= 0 && scr_y >= 0 && scr_x < 16 && scr_y < 8 && is_in_current_region(new_screen))
487 {
488 216 region_scr_dx = scr_x;
489 216 region_scr_dy = scr_y;
490 216 current_screen = new_screen;
491 216 prev_hero_scr = hero_scr;
492 216 hero_scr = get_scr(current_screen);
493 216 screen_spawned = current_screen;
494 216 playLevelMusic();
495 216 }
496
1/2
✓ Branch 0 taken 14309416 times.
✗ Branch 1 not taken.
14309416 if (game->get_regionmapping() == REGION_MAPPING_PHYSICAL)
497 mark_visited(new_screen); // Mark each screen the hero steps foot in as visited
498 14309416 }
499
500 575095 void HeroClass::set_respawn_point(bool setwarp)
501 {
502 575095 zfix oldx = x, oldy = y;
503
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 530145 times.
575095 if (replay_version_check(17))
504 {
505 530145 x = vbound(x,0,world_w-16);
506 530145 y = vbound(y,0,world_h-16);
507 530145 }
508
509
2/2
✓ Branch 0 taken 557053 times.
✓ Branch 1 taken 18042 times.
575095 if(setwarp)
510 {
511 18042 warpx = x;
512 18042 warpy = y;
513 18042 raftwarpx = x;
514 18042 raftwarpy = y;
515 18042 }
516 575095 do
517 {
518
2/2
✓ Branch 0 taken 44453 times.
✓ Branch 1 taken 530642 times.
575095 if(!get_qr(qr_OLD_RESPAWN_POINTS))
519 {
520
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 530523 times.
530642 if(cur_screen >= 0x80) break;
521 530523 bool is_safe = true;
522
2/2
✓ Branch 0 taken 461045 times.
✓ Branch 1 taken 69478 times.
530523 switch(action)
523 {
524 case none: case walking:
525 461045 break;
526 default:
527 69478 is_safe = false;
528 69478 }
529
2/2
✓ Branch 0 taken 461045 times.
✓ Branch 1 taken 69478 times.
530523 if(!is_safe) break; //unsafe action
530
5/6
✓ Branch 0 taken 457696 times.
✓ Branch 1 taken 3349 times.
✓ Branch 2 taken 457696 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 457677 times.
461045 if(z > 0 || fakez > 0 || hoverclk) break; //in air
531
4/4
✓ Branch 0 taken 5497 times.
✓ Branch 1 taken 452180 times.
✓ Branch 2 taken 1989 times.
✓ Branch 3 taken 3508 times.
457677 if(sideview_mode() && !on_sideview_solid(x,y,true)) break; //in air sideview
532
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 454029 times.
454169 if(check_pitslide(true) != -1) break; //On a pit
533
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 454018 times.
454029 if (ladderx+laddery) break; //on the ladder
534
535 { //Check water
536 454018 int32_t water = 0;
537 454018 int32_t types[4] = {0};
538 454018 int32_t x1 = x+4, x2 = x+11,
539 454018 y1 = y+9, y2 = y+15;
540
1/2
✓ Branch 0 taken 454018 times.
✗ Branch 1 not taken.
454018 if (get_qr(qr_SMARTER_WATER))
541 {
542
4/4
✓ Branch 0 taken 1905 times.
✓ Branch 1 taken 452113 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 249 times.
454280 if (iswaterex_z3(0, -1, x1, y1, true, false) &&
543
2/2
✓ Branch 0 taken 1157 times.
✓ Branch 1 taken 748 times.
1905 iswaterex_z3(0, -1, x1, y2, true, false) &&
544
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 895 times.
1157 iswaterex_z3(0, -1, x2, y1, true, false) &&
545 262 iswaterex_z3(0, -1, x2, y2, true, false)) water = iswaterex_z3(0, -1, (x2+x1)/2,(y2+y1)/2, true, false);
546 454018 }
547 else
548 {
549 types[0] = COMBOTYPE(x1,y1);
550
551 if(MAPFFCOMBO(x1,y1))
552 types[0] = FFCOMBOTYPE(x1,y1);
553
554 types[1] = COMBOTYPE(x1,y2);
555
556 if(MAPFFCOMBO(x1,y2))
557 types[1] = FFCOMBOTYPE(x1,y2);
558
559 types[2] = COMBOTYPE(x2,y1);
560
561 if(MAPFFCOMBO(x2,y1))
562 types[2] = FFCOMBOTYPE(x2,y1);
563
564 types[3] = COMBOTYPE(x2,y2);
565
566 if(MAPFFCOMBO(x2,y2))
567 types[3] = FFCOMBOTYPE(x2,y2);
568
569 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
570 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
571 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
572
573 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
574 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
575 water = typec;
576 }
577
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 453769 times.
454018 if(water > 0)
578 249 break;
579 } //End check water
580
581 2268845 rpos_t rposes[] = {
582 453769 COMBOPOS_REGION_B(x,y+(bigHitbox?0:8)),
583 453769 COMBOPOS_REGION_B(x,y+15),
584 453769 COMBOPOS_REGION_B(x+15,y+(bigHitbox?0:8)),
585 453769 COMBOPOS_REGION_B(x+15,y+15)
586 };
587
2/2
✓ Branch 0 taken 411499 times.
✓ Branch 1 taken 1697141 times.
2108640 for(auto rpos : rposes)
588 {
589
2/2
✓ Branch 0 taken 1697077 times.
✓ Branch 1 taken 64 times.
1697141 if (rpos == rpos_t::None)
590 64 continue;
591
592
2/2
✓ Branch 0 taken 1654807 times.
✓ Branch 1 taken 42270 times.
1697077 if(HASFLAG_ANY(mfUNSAFEGROUND, rpos)) //"Unsafe Ground" flag touching the player
593 {
594 42270 is_safe = false;
595 42270 break;
596 }
597 }
598
2/2
✓ Branch 0 taken 411499 times.
✓ Branch 1 taken 42270 times.
453769 if(!is_safe) break;
599 411499 }
600 455952 respawn_x = x;
601 455952 respawn_y = y;
602 455952 respawn_scr = cur_screen;
603 455952 respawn_dmap = cur_dmap;
604 455952 }
605 while(false); //run once, but 'break' works
606
607 575095 x = oldx;
608 575095 y = oldy;
609 575095 }
610
611 366144 void HeroClass::clear_ice()
612 {
613 366144 ice_vx = ice_vy = 0;
614 366144 ice_entry_count = ice_entry_mcount = 0;
615 366144 ice_combo = 0;
616 366144 sliding = 0;
617 366144 }
618 5 void HeroClass::force_ice_velocity(optional<zfix> vx, optional<zfix> vy)
619 {
620 5 auto ic = ice_combo;
621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(script_ice_combo)
622 {
623
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
5 if((unsigned(script_ice_combo) < MAXCOMBOS) && check_icy(combobuf[script_ice_combo], ICY_PLAYER))
624 5 ic = script_ice_combo;
625 else ic = 0;
626 5 }
627
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!ic) return;
628
629 5 auto const& icecmb = combobuf[ic];
630
3/6
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
5 if(script_ice_combo && ic && !sliding)
631 {
632 //Special case to prevent the forced vx/vy from being overwritten
633 5 sliding = 1;
634 5 ice_vx = ice_vy = 0;
635 5 ice_entry_count = ice_entry_mcount = icecmb.attribytes[1];
636 5 }
637
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 zfix cap = zslongToFix(zc_max(1,abs(icecmb.attributes[2])));
638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(vx) ice_vx = vbound(*vx, -cap, cap);
639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(vy) ice_vy = vbound(*vy, -cap, cap);
640 5 }
641 145 void HeroClass::go_respawn_point()
642 {
643 145 x = respawn_x;
644 145 y = respawn_y;
645 145 clear_ice();
646 145 handle_portal_prox(&mirror_portal);
647
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 portals.forEach([&](sprite& p)
648 {
649 handle_portal_prox((portal*)&p);
650 return false;
651 });
652 145 warpx=x;
653 145 warpy=y;
654 145 raftwarpx = x;
655 145 raftwarpy = y;
656 145 trySideviewLadder(); //Cling to ladder automatically
657
658
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 70 times.
145 if(get_qr(qr_OLD_RESPAWN_POINTS))
659 70 return; //No cross-screen return
660
661
2/4
✓ Branch 0 taken 75 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75 times.
75 if(cur_dmap != respawn_dmap || cur_screen != respawn_scr)
662 {
663 FFCore.warp_player(wtIWARP, respawn_dmap, respawn_scr-DMaps[cur_dmap].xoff,
664 -1, -1, 0, 0, warpFlagNOSTEPFORWARD, -1);
665 }
666 145 }
667
668 33768 void HeroClass::trySideviewLadder()
669 {
670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33768 if(canSideviewLadder() && !on_sideview_solid_oldpos(this))
671 setOnSideviewLadder(true);
672 33768 }
673
674 52369526 bool HeroClass::can_pitfall(bool ignore_hover)
675 {
676 52369526 return !(
677 52369526 isSideViewGravity()
678
2/2
✓ Branch 0 taken 51614163 times.
✓ Branch 1 taken 755363 times.
52369526 || action==rafting
679
7/8
✓ Branch 0 taken 51387428 times.
✓ Branch 1 taken 226735 times.
✓ Branch 2 taken 51349777 times.
✓ Branch 3 taken 37651 times.
✓ Branch 4 taken 51349777 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 51348679 times.
✓ Branch 7 taken 1098 times.
51614163 || z>0 || fakez>0 || fall<0 || fakefall<0
680
3/4
✓ Branch 0 taken 51348679 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 51348626 times.
51348679 || (hoverclk && !ignore_hover)
681
6/6
✓ Branch 0 taken 51325653 times.
✓ Branch 1 taken 23026 times.
✓ Branch 2 taken 51322995 times.
✓ Branch 3 taken 2658 times.
✓ Branch 4 taken 51305512 times.
✓ Branch 5 taken 17483 times.
51348679 || inlikelike || inwallm || pull_hero || toogam
682
6/6
✓ Branch 0 taken 51232684 times.
✓ Branch 1 taken 72828 times.
✓ Branch 2 taken 50735963 times.
✓ Branch 3 taken 496721 times.
✓ Branch 4 taken 50735739 times.
✓ Branch 5 taken 224 times.
51305512 || (ladderx||laddery) || getOnSideviewLadder()
683
3/4
✓ Branch 0 taken 50735739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50729393 times.
✓ Branch 3 taken 6346 times.
50735739 || drownclk || !(moveflags & move_can_pitfall)
684
2/2
✓ Branch 0 taken 50728830 times.
✓ Branch 1 taken 563 times.
50729393 || platform_ffc);
685 }
686
687 8430109 int32_t HeroClass::DrunkClock()
688 {
689 8430109 return drunkclk;
690 }
691 1 void HeroClass::setDrunkClock(int32_t newdrunkclk)
692 {
693 1 drunkclk=newdrunkclk;
694 1 }
695
696 440770 int32_t HeroClass::StunClock()
697 {
698 440770 return lstunclock;
699 }
700 378 void HeroClass::setStunClock(int32_t v)
701 {
702 378 lstunclock=v;
703 378 }
704
705 3233810596 int32_t HeroClass::BunnyClock()
706 {
707 3233810596 return lbunnyclock;
708 }
709 void HeroClass::setBunnyClock(int32_t v)
710 {
711 lbunnyclock=v;
712 }
713
714
15/30
✓ Branch 0 taken 412 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 412 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 412 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 412 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 412 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 412 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 412 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 412 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 412 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 412 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 412 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 412 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 412 times.
✗ Branch 25 not taken.
✓ Branch 26 taken 412 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 412 times.
✗ Branch 29 not taken.
824 HeroClass::HeroClass() : sprite()
715 412 {
716 412 lift_wpn = nullptr;
717
1/2
✓ Branch 0 taken 412 times.
✗ Branch 1 not taken.
412 init();
718 }
719
720 //2.6
721
722 //Stop the subscreen from falling. -Z
723
724 1383 bool HeroClass::stopSubscreenFalling(){
725 1383 return preventsubscreenfalling;
726 }
727
728 void HeroClass::stopSubscreenFalling(bool v){
729 preventsubscreenfalling = v;
730 }
731
732 14309408 void HeroClass::ClearhitHeroUIDs()
733 { //Why the flidd doesn't this work?! Clearing this to 0 in a way that doesn't demolish script access is impossible. -Z
734 //All I want, is to clear it at the end of a frame, or at the start of a frame, so that if it changes to non-0
735 //that a script can read it before Waitdraw(). --I want it to go stale at the end of a frame.
736 //I suppose I will need to do this inside the script engine, and not the game_loop() ? -Z
737 //THis started out as a simple clear to 0 of lastHitBy[n], but that did not work:
738 //I added the second element to this, so that I could store the frame on which the hit is recorded, and
739 //clear it on the next frame, but that had the SAME outcome.
740 //Where and how can I clear a value at the end of every frame, so that:
741 // 1. If set by internal mecanics, it has its value that you can read by script, before waitdraw--this part works at present.
742 // 2. FFCs can read it before Waitframe. --same.
743 // 3. After Waitframe(), it is wiped by the ZC Engine to 0. --I cannot get this to happen without breaking 1 and 2.
744
2/2
✓ Branch 0 taken 243259936 times.
✓ Branch 1 taken 14309408 times.
257569344 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ )
745 {
746 /*
747 if ( lastHitBy[q][1] == (frame-1) ) //Verify if this is needed at all now.
748 {
749 //Z_scripterrlog("frame is: %d\n", frame);
750 //Z_scripterrlog("Player->HitBy frame is: %d\n", lastHitBy[q][1]);
751 lastHitBy[q][0] = 0;
752 }
753 */
754 243259936 lastHitBy[q][0] = 0;
755 243259936 }
756 14309408 }
757
758 77142 void HeroClass::sethitHeroUID(int32_t type, int32_t screen)
759 {
760 77142 lastHitBy[type][0] = screen;
761 77142 }
762
763 3244 int32_t HeroClass::gethitHeroUID(int32_t type)
764 {
765 3244 return lastHitBy[type][0];
766 }
767
768 void HeroClass::set_defence(int32_t type, int32_t v)
769 {
770 defence[type] = v;
771 }
772
773 int32_t HeroClass::get_defence(int32_t type)
774 {
775 return defence[type];
776 }
777
778
779 //Set Hero;s hurt sfx
780 277656 void HeroClass::setHurtSFX(int32_t sfx)
781 {
782 277656 QMisc.miscsfx[sfxHURTPLAYER] = sfx;
783 277656 }
784 15551 int32_t HeroClass::getHurtSFX()
785 {
786 15551 return QMisc.miscsfx[sfxHURTPLAYER];
787 }
788
789 bool HeroClass::getDiagMove()
790 {
791 return diagonalMovement;
792 }
793 1116 void HeroClass::setDiagMove(bool newdiag)
794 {
795 1116 diagonalMovement=newdiag;
796 1116 }
797 271788 bool HeroClass::getBigHitbox()
798 {
799 271788 return bigHitbox;
800 }
801 2665 void HeroClass::setBigHitbox(bool newbigHitbox)
802 {
803 2665 bigHitbox=newbigHitbox;
804 2665 syofs = bigHitbox?0:8;
805 2665 sysz_ofs = bigHitbox?0:-8;
806 2665 }
807 6376 int32_t HeroClass::getStepRate()
808 {
809 6376 return steprate;
810 }
811 952 void HeroClass::setStepRate(int32_t newrate)
812 {
813 952 steprate = newrate;
814 952 }
815 int32_t HeroClass::getSwimUpRate()
816 {
817 return game->get_sideswim_up();
818 }
819 void HeroClass::setSwimUpRate(int32_t newrate)
820 {
821 game->set_sideswim_up(newrate);
822 }
823 int32_t HeroClass::getSwimSideRate()
824 {
825 return game->get_sideswim_side();
826 }
827 void HeroClass::setSwimSideRate(int32_t newrate)
828 {
829 game->set_sideswim_side(newrate);
830 }
831 int32_t HeroClass::getSwimDownRate()
832 {
833 return game->get_sideswim_down();
834 }
835 void HeroClass::setSwimDownRate(int32_t newrate)
836 {
837 game->set_sideswim_down(newrate);
838 }
839
840
841 10524533 void HeroClass::herostep()
842 {
843
2/2
✓ Branch 0 taken 9866563 times.
✓ Branch 1 taken 657970 times.
10524533 lstep = lstep<((zinit.heroAnimationStyle==las_bszelda)?27:11) ? lstep+1 : 0;
844 //need to run all global/hero/dmap scripts here?
845 10524533 }
846
847 142451 bool is_moving()
848 {
849
6/6
✓ Branch 0 taken 110147 times.
✓ Branch 1 taken 32304 times.
✓ Branch 2 taken 82023 times.
✓ Branch 3 taken 28124 times.
✓ Branch 4 taken 32573 times.
✓ Branch 5 taken 49450 times.
142451 return getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION);
850 }
851
852 // called by ALLOFF()
853 36439 void HeroClass::resetflags(bool all)
854 {
855 36439 refilling=REFILL_NONE;
856 36439 inwallm=false;
857 36439 inlikelike=blowcnt=whirlwind=specialcave=hclk=fairyclk=refill_why=didstuff=0;
858 36439 usecounts.clear();
859 36439 item_cooldown.fill(0);
860
861
4/4
✓ Branch 0 taken 36355 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 35933 times.
36439 if(swordclk>0 || all)
862 {
863 506 swordclk=0;
864 506 verifyAWpn();
865 506 }
866
4/4
✓ Branch 0 taken 36418 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 35996 times.
36439 if(itemclk>0 || all)
867 443 itemclk=0;
868
3/4
✓ Branch 0 taken 36439 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 422 times.
✓ Branch 3 taken 36017 times.
36439 if(shieldjinxclk>0 || all)
869 422 shieldjinxclk=0;
870
871
2/2
✓ Branch 0 taken 36017 times.
✓ Branch 1 taken 422 times.
36439 if(all)
872 {
873 422 DivineProtectionShieldClk=0;
874
875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 422 times.
422 if(div_prot_item != -1)
876 {
877 stop_sfx(itemsbuf[div_prot_item].usesound);
878 stop_sfx(itemsbuf[div_prot_item].usesound+1);
879 }
880
881 422 div_prot_item = -1;
882 422 hoverclk=jumping=0;
883 422 hoverflags = 0;
884 422 }
885 36439 damageovertimeclk = 0;
886 36439 newconveyorclk = 0;
887 36439 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
888
2/2
✓ Branch 0 taken 36439 times.
✓ Branch 1 taken 255073 times.
291512 for(auto q = 0; q < 7; ++q)
889 255073 hooked_undercombos[q] = -1;
890 36439 hopclk=0;
891 36439 hopdir=-1;
892 36439 attackclk=0;
893 36439 stomping=false;
894 36439 reset_swordcharge();
895 36439 diveclk=drownclk=drownCombo=0;
896 36439 action=none; FFCore.setHeroAction(none);
897 36439 conveyor_flags=0;
898 36439 magiccastclk=0;
899 36439 magicitem=-1;
900 36439 }
901
902 //Can use this for Hero->Stun. -Z
903 14701 void HeroClass::Freeze()
904 {
905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14701 times.
14701 if (action != inwind)
906 {
907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14701 times.
14701 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
908 14701 else {action=freeze; FFCore.setHeroAction(freeze);}
909 // also cancel Hero's attack
910 14701 attackclk = 0;
911 14701 }
912 14701 }
913 3738 void HeroClass::unfreeze()
914 {
915
4/4
✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 2450 times.
✓ Branch 2 taken 1287 times.
✓ Branch 3 taken 1 times.
3738 if(action==freeze && fairyclk<1) { action=none; FFCore.setHeroAction(none); }
916
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3738 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3738 if(action==sideswimfreeze && fairyclk<1) { action=sideswimming; FFCore.setHeroAction(sideswimming); }
917 3738 }
918
919 194 void HeroClass::Drown(int32_t state)
920 {
921 // Hero should never drown if the ladder is out
922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 194 times.
194 if(ladderx+laddery)
923 return;
924
925 194 drop_liftwpn();
926
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 4 times.
194 switch(state)
927 {
928 case 1:
929 4 action=lavadrowning; FFCore.setHeroAction(lavadrowning);
930 4 attackclk=0;
931 4 attack=wNone;
932 4 attackid=-1;
933 4 reset_swordcharge();
934 4 drownclk=64;
935 4 z=fakez=fall=fakefall=0;
936 4 break;
937
938
939 default:
940 {
941
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
190 if (isSideViewHero() && get_qr(qr_SIDESWIM)){action=sidedrowning; FFCore.setHeroAction(sidedrowning);}
942 190 else {action=drowning; FFCore.setHeroAction(drowning);}
943 190 attackclk=0;
944 190 attack=wNone;
945 190 attackid=-1;
946 190 reset_swordcharge();
947 190 drownclk=64;
948 190 z=fakez=fall=fakefall=0;
949 190 break;
950 }
951 }
952
953 194 }
954
955 2410 void HeroClass::finishedmsg()
956 {
957 //these are to cancel out any keys that Hero may
958 //be pressing so he doesn't attack at the end of
959 //a message if he was scrolling through it quickly.
960 2410 getInput(btnA, INPUT_PRESS | INPUT_HERO_ACTION);
961 2410 getInput(btnB, INPUT_PRESS | INPUT_HERO_ACTION);
962 2410 unfreeze();
963
964
3/4
✓ Branch 0 taken 2308 times.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2277 times.
4687 if(action == landhold1 ||
965
2/2
✓ Branch 0 taken 2279 times.
✓ Branch 1 taken 29 times.
2308 action == landhold2 ||
966
2/2
✓ Branch 0 taken 2278 times.
✓ Branch 1 taken 1 times.
2279 action == waterhold1 ||
967
2/2
✓ Branch 0 taken 2277 times.
✓ Branch 1 taken 1 times.
2278 action == waterhold2 ||
968
1/2
✓ Branch 0 taken 2277 times.
✗ Branch 1 not taken.
2277 action == sidewaterhold1 ||
969 2277 action == sidewaterhold2)
970 {
971 133 holdclk = 1;
972 133 }
973 2410 }
974 78 void HeroClass::setEaten(int32_t i)
975 {
976 78 inlikelike=i;
977 78 }
978 70 int32_t HeroClass::getEaten()
979 {
980 70 return inlikelike;
981 }
982 48643980 zfix HeroClass::getX()
983 {
984 48643980 return x;
985 }
986 49016980 zfix HeroClass::getY()
987 {
988 49016980 return y;
989 }
990 90481103 zfix HeroClass::getZ()
991 {
992 90481103 return z;
993 }
994 55596403 zfix HeroClass::getFakeZ()
995 {
996 55596403 return fakez;
997 }
998 zfix HeroClass::getFall()
999 {
1000 return fall;
1001 }
1002 741274 zfix HeroClass::getJump()
1003 {
1004 741274 return fall / -100;
1005 }
1006 zfix HeroClass::getFakeFall()
1007 {
1008 return fakefall;
1009 }
1010 zfix HeroClass::getFakeJump()
1011 {
1012 return fakefall / -100;
1013 }
1014 zfix HeroClass::getXOfs()
1015 {
1016 return xofs;
1017 }
1018 1344 zfix HeroClass::getYOfs()
1019 {
1020 1344 return yofs;
1021 }
1022 void HeroClass::setXOfs(int32_t newxofs)
1023 {
1024 xofs=newxofs;
1025 }
1026 void HeroClass::setYOfs(int32_t newyofs)
1027 {
1028 yofs=newyofs;
1029 }
1030 int32_t HeroClass::getHXOfs()
1031 {
1032 return hxofs;
1033 }
1034 int32_t HeroClass::getHYOfs()
1035 {
1036 return hyofs;
1037 }
1038 int32_t HeroClass::getHXSz()
1039 {
1040 return hit_width;
1041 }
1042 int32_t HeroClass::getHYSz()
1043 {
1044 return hit_height;
1045 }
1046 88384 zfix HeroClass::getClimbCoverX()
1047 {
1048 88384 return climb_cover_x;
1049 }
1050 88384 zfix HeroClass::getClimbCoverY()
1051 {
1052 88384 return climb_cover_y;
1053 }
1054 int32_t HeroClass::getLadderX()
1055 {
1056 return ladderx;
1057 }
1058 int32_t HeroClass::getLadderY()
1059 {
1060 return laddery;
1061 }
1062
1063 462619 void HeroClass::setX(int32_t new_x)
1064 {
1065 462619 zfix dx=new_x-x;
1066 462619 justmoved = 2;
1067
2/2
✓ Branch 0 taken 462598 times.
✓ Branch 1 taken 21 times.
462619 if(Lwpns.idFirst(wHookshot)>-1)
1068 {
1069 21 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
1070 21 hs_startx+=(int32_t)dx;
1071 21 }
1072
1073
2/2
✓ Branch 0 taken 462598 times.
✓ Branch 1 taken 21 times.
462619 if(Lwpns.idFirst(wHSHandle)>-1)
1074 {
1075 21 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
1076 21 }
1077
1078
2/2
✓ Branch 0 taken 462610 times.
✓ Branch 1 taken 9 times.
462619 if(chainlinks.Count()>0)
1079 {
1080
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 9 times.
28 for(int32_t j=0; j<chainlinks.Count(); j++)
1081 {
1082 19 chainlinks.spr(j)->x+=dx;
1083 19 }
1084 9 }
1085
1086 462619 x=new_x;
1087
1088 // A kludge
1089
4/4
✓ Branch 0 taken 3710 times.
✓ Branch 1 taken 458909 times.
✓ Branch 2 taken 2385 times.
✓ Branch 3 taken 1325 times.
462619 if(!diagonalMovement && dir<=down)
1090 1325 is_on_conveyor = -1;
1091 462619 }
1092
1093 482940 void HeroClass::setY(int32_t new_y)
1094 {
1095 482940 zfix dy=new_y-y;
1096 482940 justmoved = 2;
1097
2/2
✓ Branch 0 taken 482931 times.
✓ Branch 1 taken 9 times.
482940 if(Lwpns.idFirst(wHookshot)>-1)
1098 {
1099 9 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
1100 9 hs_starty+=(int32_t)dy;
1101 9 }
1102
1103
2/2
✓ Branch 0 taken 482931 times.
✓ Branch 1 taken 9 times.
482940 if(Lwpns.idFirst(wHSHandle)>-1)
1104 {
1105 9 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
1106 9 }
1107
1108
1/2
✓ Branch 0 taken 482940 times.
✗ Branch 1 not taken.
482940 if(chainlinks.Count()>0)
1109 {
1110 for(int32_t j=0; j<chainlinks.Count(); j++)
1111 {
1112 chainlinks.spr(j)->y+=dy;
1113 }
1114 }
1115
1116 482940 y=new_y;
1117
1118 // A kludge
1119
4/4
✓ Branch 0 taken 3710 times.
✓ Branch 1 taken 479230 times.
✓ Branch 2 taken 1325 times.
✓ Branch 3 taken 2385 times.
482940 if(!diagonalMovement && dir>=left)
1120 2385 is_on_conveyor = -1;
1121 482940 }
1122
1123 4 void HeroClass::setZ(int32_t new_z)
1124 {
1125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(isSideViewHero())
1126 return;
1127
1128
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(z==0 && new_z > 0)
1129 {
1130
1/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 switch(action)
1131 {
1132 case swimming:
1133 {
1134 diveclk=0;
1135 action=walking; FFCore.setHeroAction(walking);
1136 break;
1137 }
1138
1139 case waterhold1:
1140 {
1141 action=landhold1; FFCore.setHeroAction(landhold1);
1142 break;
1143 }
1144
1145 case waterhold2:
1146 {
1147 action=landhold2; FFCore.setHeroAction(landhold2);
1148 break;
1149 }
1150
1151 default:
1152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(charging) //!DIMITODO: Let Hero jump while charging sword
1153 {
1154 reset_swordcharge();
1155 attackclk=0;
1156 }
1157
1158 4 break;
1159 }
1160 4 }
1161
1162
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 z=(new_z>0 ? new_z : 0);
1163 4 }
1164
1165 void HeroClass::setFakeZ(int32_t new_z)
1166 {
1167 if(isSideViewHero())
1168 return;
1169
1170 if(fakez==0 && new_z > 0)
1171 {
1172 switch(action)
1173 {
1174 case swimming:
1175 {
1176 diveclk=0;
1177 action=walking; FFCore.setHeroAction(walking);
1178 break;
1179 }
1180
1181 case waterhold1:
1182 {
1183 action=landhold1; FFCore.setHeroAction(landhold1);
1184 break;
1185 }
1186
1187 case waterhold2:
1188 {
1189 action=landhold2; FFCore.setHeroAction(landhold2);
1190 break;
1191 }
1192
1193 default:
1194 if(charging) //!DIMITODO: Let Hero jump while charging sword
1195 {
1196 reset_swordcharge();
1197 attackclk=0;
1198 }
1199
1200 break;
1201 }
1202 }
1203
1204 fakez=(new_z>0 ? new_z : 0);
1205 }
1206
1207 25176 void HeroClass::setXfix(zfix new_x)
1208 {
1209 //Z_scripterrlog("setxdbl: %f\n",new_x);
1210 25176 zfix dx=new_x-x;
1211 25176 justmoved = 2;
1212
2/2
✓ Branch 0 taken 25166 times.
✓ Branch 1 taken 10 times.
25176 if(Lwpns.idFirst(wHookshot)>-1)
1213 {
1214 10 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=dx;
1215 10 hs_startx+=(int32_t)dx;
1216 10 }
1217
1218
2/2
✓ Branch 0 taken 25166 times.
✓ Branch 1 taken 10 times.
25176 if(Lwpns.idFirst(wHSHandle)>-1)
1219 {
1220 10 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=dx;
1221 10 }
1222
1223
2/2
✓ Branch 0 taken 25169 times.
✓ Branch 1 taken 7 times.
25176 if(chainlinks.Count()>0)
1224 {
1225
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 7 times.
22 for(int32_t j=0; j<chainlinks.Count(); j++)
1226 {
1227 15 chainlinks.spr(j)->x+=dx;
1228 15 }
1229 7 }
1230
1231 25176 x=new_x;
1232
1233 // A kludge
1234
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25176 if(!diagonalMovement && dir<=down)
1235 is_on_conveyor = -1;
1236 25176 }
1237
1238 24356 void HeroClass::setYfix(zfix new_y)
1239 {
1240 24356 zfix dy=new_y-y;
1241 24356 justmoved = 2;
1242
2/2
✓ Branch 0 taken 24316 times.
✓ Branch 1 taken 40 times.
24356 if(Lwpns.idFirst(wHookshot)>-1)
1243 {
1244 40 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=dy;
1245 40 hs_starty+=(int32_t)dy;
1246 40 }
1247
1248
2/2
✓ Branch 0 taken 24316 times.
✓ Branch 1 taken 40 times.
24356 if(Lwpns.idFirst(wHSHandle)>-1)
1249 {
1250 40 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=dy;
1251 40 }
1252
1253
2/2
✓ Branch 0 taken 24322 times.
✓ Branch 1 taken 34 times.
24356 if(chainlinks.Count()>0)
1254 {
1255
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 34 times.
213 for(int32_t j=0; j<chainlinks.Count(); j++)
1256 {
1257 179 chainlinks.spr(j)->y+=dy;
1258 179 }
1259 34 }
1260
1261 24356 y=new_y;
1262
1263 // A kludge
1264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24356 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
24356 if(!diagonalMovement && dir>=left)
1265 is_on_conveyor = -1;
1266 24356 }
1267
1268 2779 void HeroClass::setZfix(zfix new_z)
1269 {
1270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2779 times.
2779 if(isSideViewHero())
1271 return;
1272
1273
4/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 2758 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 15 times.
2779 if(z==0 && new_z > 0)
1274 {
1275
1/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 switch(action)
1276 {
1277 case swimming:
1278 {
1279 diveclk=0;
1280 action=walking; FFCore.setHeroAction(walking);
1281 break;
1282 }
1283
1284 case waterhold1:
1285 {
1286 action=landhold1; FFCore.setHeroAction(landhold1);
1287 break;
1288 }
1289
1290 case waterhold2:
1291 {
1292 action=landhold2; FFCore.setHeroAction(landhold2);
1293 break;
1294 }
1295
1296 default:
1297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(charging) //!DIMITODO: Let Hero jump while charging sword
1298 {
1299 reset_swordcharge();
1300 attackclk=0;
1301 }
1302
1303 15 break;
1304 }
1305 15 }
1306
1307
2/2
✓ Branch 0 taken 2771 times.
✓ Branch 1 taken 8 times.
2779 z=(new_z>0 ? new_z : 0_zf);
1308 2779 }
1309
1310 void HeroClass::setFakeZfix(zfix new_z)
1311 {
1312 if(isSideViewHero())
1313 return;
1314
1315 if(fakez==0 && new_z > 0)
1316 {
1317 switch(action)
1318 {
1319 case swimming:
1320 {
1321 diveclk=0;
1322 action=walking; FFCore.setHeroAction(walking);
1323 break;
1324 }
1325
1326 case waterhold1:
1327 {
1328 action=landhold1; FFCore.setHeroAction(landhold1);
1329 break;
1330 }
1331
1332 case waterhold2:
1333 {
1334 action=landhold2; FFCore.setHeroAction(landhold2);
1335 break;
1336 }
1337
1338 default:
1339 if(charging) //!DIMITODO: Let Hero jump while charging sword
1340 {
1341 reset_swordcharge();
1342 attackclk=0;
1343 }
1344
1345 break;
1346 }
1347 }
1348
1349 fakez=(new_z>0 ? new_z : 0_zf);
1350 }
1351
1352 77190 void HeroClass::setFall(zfix new_fall)
1353 {
1354 77190 fall = new_fall;
1355 77190 justmoved = 2;
1356
3/4
✓ Branch 0 taken 10930 times.
✓ Branch 1 taken 66260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 66260 times.
77190 if (!jumping && fall || !get_qr(qr_BETTER_PLAYER_JUMP_ANIM))
1357 77190 jumping = -1;
1358 77190 }
1359 void HeroClass::setFakeFall(zfix new_fall)
1360 {
1361 fakefall = new_fall;
1362 if (!jumping && fakefall || !get_qr(qr_BETTER_PLAYER_JUMP_ANIM))
1363 jumping = -1;
1364 }
1365 76838 void HeroClass::setJump(zfix new_jump)
1366 {
1367 76838 setFall(new_jump*-100);
1368 76838 }
1369 void HeroClass::setFakeJump(zfix new_jump)
1370 {
1371 setFakeFall(new_jump*-100);
1372 }
1373 void HeroClass::setClimbCoverX(int32_t new_x)
1374 {
1375 climb_cover_x=new_x;
1376 }
1377 void HeroClass::setClimbCoverY(int32_t new_y)
1378 {
1379 climb_cover_y=new_y;
1380 }
1381 138971 int32_t HeroClass::getLStep()
1382 {
1383 138971 return lstep;
1384 }
1385 5804 int32_t HeroClass::getCharging()
1386 {
1387 5804 return charging;
1388 }
1389 127714 bool HeroClass::isCharged()
1390 {
1391 127714 return spins>0;
1392 }
1393 2 int32_t HeroClass::getAttackClk()
1394 {
1395 2 return attackclk;
1396 }
1397 2 void HeroClass::setAttackClk(int32_t new_clk)
1398 {
1399 2 attackclk=new_clk;
1400 2 }
1401 void HeroClass::setCharging(int32_t new_charging)
1402 {
1403 charging=new_charging;
1404 }
1405 3026302487 int32_t HeroClass::getSwordClk()
1406 {
1407 3026302487 return swordclk;
1408 }
1409 2958101289 int32_t HeroClass::getItemClk()
1410 {
1411 2958101289 return itemclk;
1412 }
1413 2971975780 int32_t HeroClass::getShieldClk()
1414 {
1415 2971975780 return shieldjinxclk;
1416 }
1417 720 void HeroClass::setSwordClk(int32_t newclk)
1418 {
1419 720 swordclk=newclk;
1420 720 verifyAWpn();
1421 720 }
1422 5880 void HeroClass::setItemClk(int32_t newclk)
1423 {
1424 5880 itemclk=newclk;
1425 5880 }
1426 2 void HeroClass::setShieldClk(int32_t newclk)
1427 {
1428 2 shieldjinxclk=newclk;
1429 2 }
1430 // TODO remove, no longer needed.
1431 1165909 zfix HeroClass::getModifiedX()
1432 {
1433 1165909 zfix tempx=x;
1434 1165909 return tempx;
1435 }
1436
1437 1165909 zfix HeroClass::getModifiedY()
1438 {
1439 1165909 zfix tempy=y;
1440 1165909 return tempy;
1441 }
1442
1443 64175 int32_t HeroClass::getDir()
1444 {
1445 64175 return dir;
1446 }
1447 95580 void HeroClass::setDir(int32_t newdir)
1448 {
1449 95580 dir=newdir;
1450 95580 reset_hookshot();
1451 95580 }
1452 441276 int32_t HeroClass::getHitDir()
1453 {
1454 441276 return hitdir;
1455 }
1456 2220 void HeroClass::setHitDir(int32_t newdir)
1457 {
1458 2220 hitdir = newdir;
1459 2220 }
1460 int32_t HeroClass::getClk()
1461 {
1462 return clk;
1463 }
1464 180367 int32_t HeroClass::getPushing()
1465 {
1466 180367 return pushing;
1467 }
1468 15591 void HeroClass::Catch()
1469 {
1470
5/6
✓ Branch 0 taken 15591 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12611 times.
✓ Branch 3 taken 2980 times.
✓ Branch 4 taken 6231 times.
✓ Branch 5 taken 6380 times.
15591 if(!inwallm && (action==none || action==walking))
1471 {
1472 9211 SetAttack();
1473 9211 attackclk=0;
1474 9211 attack=wCatching;
1475 9211 }
1476 15591 }
1477
1478 4421336 bool HeroClass::getClock()
1479 {
1480 4421336 return superman;
1481 }
1482 954 void HeroClass::setClock(bool state)
1483 {
1484 954 superman=state;
1485 954 }
1486 16731574 int32_t HeroClass::getFlashingCSet()
1487 {
1488 16731574 int32_t temp_cs = 6;
1489
2/2
✓ Branch 0 taken 16477195 times.
✓ Branch 1 taken 254379 times.
16731574 if (script_hero_cset > -1) temp_cs = script_hero_cset;
1490
2/2
✓ Branch 0 taken 2344626 times.
✓ Branch 1 taken 14386948 times.
16731574 if (!get_qr(qr_HEROFLICKER))
1491 {
1492
3/4
✓ Branch 0 taken 131470 times.
✓ Branch 1 taken 14255478 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 131470 times.
14386948 if (superman && getCanFlicker())
1493 {
1494 131470 temp_cs += (((~frame) >> 1) & 3);
1495 131470 }
1496
4/6
✓ Branch 0 taken 634214 times.
✓ Branch 1 taken 13621264 times.
✓ Branch 2 taken 634214 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 634214 times.
14255478 else if (hclk && (DivineProtectionShieldClk <= 0) && getCanFlicker())
1497 {
1498 634214 temp_cs += ((hclk >> 1) & 3);
1499 634214 }
1500 14386948 }
1501 16731574 return temp_cs;
1502 }
1503 17654558 bool HeroClass::is_hitflickerframe()
1504 {
1505
6/6
✓ Branch 0 taken 2496469 times.
✓ Branch 1 taken 15158089 times.
✓ Branch 2 taken 2433668 times.
✓ Branch 3 taken 62801 times.
✓ Branch 4 taken 107429 times.
✓ Branch 5 taken 2326239 times.
17654558 if (!(get_qr(qr_HEROFLICKER) && (superman || hclk)))
1506 17484328 return false;
1507
1508 170230 int32_t fr = game->get_spriteflickerspeed();
1509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170230 times.
170230 if (fr == 0)
1510 return true;
1511 170230 return frame % (fr * 2) >= fr;
1512 17654558 }
1513 109743758 int32_t HeroClass::getAction() // Used by ZScript
1514 {
1515
2/2
✓ Branch 0 taken 34580 times.
✓ Branch 1 taken 109709178 times.
109743758 if(spins > 0)
1516 34580 return isspinning;
1517
2/2
✓ Branch 0 taken 410457 times.
✓ Branch 1 taken 109298721 times.
109709178 else if(charging > 0)
1518 410457 return ischarging;
1519
2/2
✓ Branch 0 taken 109176051 times.
✓ Branch 1 taken 122670 times.
109298721 else if(diveclk > 0)
1520 122670 return isdiving;
1521 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1522
1523 109176051 return action;
1524 109743758 }
1525
1526 92677417 int32_t HeroClass::getAction2() // Used by ZScript new FFCore.actions
1527 {
1528
2/2
✓ Branch 0 taken 25963 times.
✓ Branch 1 taken 92651454 times.
92677417 if(spins > 0)
1529 25963 return isspinning;
1530
2/2
✓ Branch 0 taken 333968 times.
✓ Branch 1 taken 92317486 times.
92651454 else if(charging > 0)
1531 333968 return ischarging;
1532
2/2
✓ Branch 0 taken 92118537 times.
✓ Branch 1 taken 198949 times.
92317486 else if(diveclk > 0)
1533 198949 return isdiving;
1534 //else if (pushing > 0) return ispushing; //Needs a QR? -Z or make it an instruction as Hero->Pushing? Probably better, as that has a clk??
1535
1536 92118537 return -1;
1537 92677417 }
1538
1539 5206 void HeroClass::setAction(actiontype new_action) // Used by ZScript
1540 {
1541
4/8
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5206 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5206 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5206 times.
10412 if(new_action==dying || new_action==won || new_action==scrolling ||
1542
3/6
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5206 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5206 times.
✗ Branch 5 not taken.
5206 new_action==inwind || new_action==ischarging || new_action==sideswimischarging ||
1543 5206 new_action==hopping) //!DIMITODO: allow setting sideswimming stuff
1544 return; // Can't use these actions.
1545
1546
3/6
✓ Branch 0 taken 4950 times.
✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4950 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5206 if (!isSideViewHero() && (new_action>=sideswimming && new_action <= sideswimischarging))
1547 return;
1548
1549
1/2
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
5206 if(new_action==rafting)
1550 {
1551 if(get_qr(qr_DISALLOW_SETTING_RAFTING)) return;
1552 if(!(isRaftFlag(nextflag(x+8,y+8,dir,false))||isRaftFlag(nextflag(x+8,y+8,dir,true))))
1553 return;
1554 }
1555
1556
1557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5206 if(magicitem>-1 && itemsbuf[magicitem].type==itype_divineescape)
1558 {
1559 // Using Divine Escape
1560 if(magiccastclk<96)
1561 {
1562 // Not cast yet; cancel it
1563 magicitem=-1;
1564 magiccastclk=0;
1565 }
1566 else
1567 // Already activated; don't do anything
1568 return;
1569 }
1570
1571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
5206 if(action==inwind) // Remove from whirlwind
1572 {
1573 xofs=0;
1574 whirlwind=0;
1575 lstep=0;
1576 if ( dontdraw < 2 ) { dontdraw=0; }
1577 }
1578
2/4
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5206 times.
5206 else if(action==freeze||action==sideswimfreeze) // Might be in enemy wind
1579 {
1580 sprite* wind=0;
1581 bool foundWind=false;
1582 for(int32_t i=0; i<Ewpns.Count(); i++)
1583 {
1584 wind=Ewpns.spr(i);
1585 if(wind->id==ewWind && wind->misc==999)
1586 {
1587 foundWind=true;
1588 break;
1589 }
1590 }
1591
1592 if(foundWind)
1593 {
1594 xofs=0;
1595 if ( dontdraw < 2 ) { dontdraw=false; }
1596 wind->misc=-1;
1597 x=wind->x;
1598 y=wind->y;
1599 }
1600 }
1601
1602 //Unless compat rule is on, reset hopping clocks when writing action!
1603
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5206 if(action == hopping && !get_qr(qr_NO_OVERWRITING_HOPPING))
1604 {
1605 hopclk = 0;
1606 hopdir = -1;
1607 }
1608
1609
3/4
✓ Branch 0 taken 2783 times.
✓ Branch 1 taken 2423 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2783 times.
5206 if(new_action != attacking && new_action != sideswimattacking)
1610 {
1611 2783 attackclk=0;
1612
1613
1/2
✓ Branch 0 taken 2783 times.
✗ Branch 1 not taken.
2783 if(attack==wHookshot)
1614 reset_hookshot();
1615 2783 }
1616
2/4
✓ Branch 0 taken 5206 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5206 times.
5206 if(new_action != isspinning && new_action != sideswimisspinning)
1617 {
1618 5206 charging = 0;
1619 5206 spins = 0;
1620 5206 }
1621
1622
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5206 if(action == falling && new_action != falling)
1623 {
1624 fallclk = 0; //Stop falling;
1625 }
1626
1627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5206 if (action == rafting && new_action != rafting)
1628 {
1629 raftwarpx = x;//If you wanted to make Link stop rafting on a dock combo, don't make the dock retrigger the raft.
1630 raftwarpy = y;
1631 }
1632
1633
4/9
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2423 times.
✓ Branch 5 taken 2765 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5206 switch(new_action)
1634 {
1635 case isspinning:
1636 case sideswimisspinning:
1637 if(attack==wSword)
1638 {
1639 attackclk = SWORDCHARGEFRAME+1;
1640 charging = 0;
1641
1642 if(spins==0)
1643 spins = 5;
1644 }
1645 return;
1646
1647 case isdiving:
1648 if(action==swimming && diveclk==0)
1649 {
1650 int32_t flippers_id = current_item_id(itype_flippers);
1651 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2)); // Who cares about qr_NODIVING? It's the questmaker's business.
1652 }
1653 return;
1654
1655 case drowning:
1656 case sidedrowning:
1657 clear_platform_ffc();
1658 if(!drownclk)
1659 Drown();
1660
1661 break;
1662
1663 case lavadrowning:
1664 //Lavadrowning is just drowning but with a different argument. Simplicity! -Dimi
1665 clear_platform_ffc();
1666 if(!drownclk)
1667 Drown(1);
1668
1669 break;
1670
1671 case falling:
1672 clear_platform_ffc();
1673 if(!fallclk)
1674 {
1675 //If there is a pit under Hero, use its combo.
1676 if(int32_t c = getpitfall(x+8,y+(bigHitbox?8:12))) fallCombo = c;
1677 else if(int32_t c = getpitfall(x,y+(bigHitbox?0:8))) fallCombo = c;
1678 else if(int32_t c = getpitfall(x+15,y+(bigHitbox?0:8))) fallCombo = c;
1679 else if(int32_t c = getpitfall(x,y+15)) fallCombo = c;
1680 else if(int32_t c = getpitfall(x+15,y+15)) fallCombo = c;
1681 //Else, use a null value; triggers default pit values
1682 else fallCombo = 0;
1683 fallclk = PITFALL_FALL_FRAMES;
1684 }
1685 break;
1686
1687 case gothit:
1688 case swimhit:
1689 case sideswimhit:
1690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!hclk)
1691 1 hclk=48;
1692 1 check_on_hit();
1693 1 break;
1694
1695 case landhold1:
1696 case landhold2:
1697 case waterhold1:
1698 case waterhold2:
1699 case sidewaterhold1:
1700 case sidewaterhold2:
1701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!holdclk)
1702 17 holdclk=130;
1703
1704 17 attack=none;
1705 17 break;
1706
1707 case attacking:
1708 case sideswimattacking:
1709 2423 attack=none;
1710 2423 break;
1711
1712 default:
1713 2765 break;
1714 }
1715
1716 5206 action=new_action; FFCore.setHeroAction(new_action);
1717 5206 }
1718
1719 48 void HeroClass::setHeldItem(int32_t newitem)
1720 {
1721 48 holditem=newitem;
1722 48 }
1723 204 int32_t HeroClass::getHeldItem()
1724 {
1725 204 return holditem;
1726 }
1727 20621597 bool HeroClass::isDiving()
1728 {
1729 20621597 int32_t flippers_id = current_item_id(itype_flippers);
1730
2/2
✓ Branch 0 taken 15177244 times.
✓ Branch 1 taken 5444353 times.
20621597 return (diveclk > (flippers_id < 0 ? 30 : itemsbuf[flippers_id].misc2));
1731 }
1732 45247996 bool HeroClass::isSwimming()
1733 {
1734 45247996 bool include_swimhit = true;
1735
3/4
✓ Branch 0 taken 45247996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8798310 times.
✓ Branch 3 taken 36449686 times.
45247996 if (replay_is_active() && replay_version_check(0, 31))
1736 {
1737
2/4
✓ Branch 0 taken 36449686 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36449686 times.
36449686 std::string qst = replay_get_meta_str("qst");
1738 36449686 bool disable = false;
1739
1/2
✓ Branch 0 taken 36449686 times.
✗ Branch 1 not taken.
36449686 disable |= qst == "demons_inferno.qst";
1740
1/2
✓ Branch 0 taken 36449686 times.
✗ Branch 1 not taken.
36449686 disable |= qst == "demosp253.qst";
1741
1/2
✓ Branch 0 taken 36449686 times.
✗ Branch 1 not taken.
36449686 disable |= qst == "hell_awaits.qst";
1742
1/2
✓ Branch 0 taken 36449686 times.
✗ Branch 1 not taken.
36449686 disable |= qst == "lands_of_serenity.qst";
1743
1/2
✓ Branch 0 taken 36449686 times.
✗ Branch 1 not taken.
36449686 disable |= qst == "link_to_the_heavens.qst";
1744 // The others are just a gfx change, but this one actual breaks without this compat check.
1745
1/2
✓ Branch 0 taken 36449686 times.
✗ Branch 1 not taken.
36449686 disable |= qst == "link_to_the_zelda.qst";
1746 36449686 include_swimhit = !disable;
1747 36449686 }
1748
4/6
✓ Branch 0 taken 44796792 times.
✓ Branch 1 taken 451204 times.
✓ Branch 2 taken 44796792 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 44796792 times.
✗ Branch 5 not taken.
90044788 return ((action==swimming)||(action==sideswimming)||IsSideSwim()||
1749
8/8
✓ Branch 0 taken 44792779 times.
✓ Branch 1 taken 4013 times.
✓ Branch 2 taken 44790020 times.
✓ Branch 3 taken 2759 times.
✓ Branch 4 taken 28310049 times.
✓ Branch 5 taken 16479971 times.
✓ Branch 6 taken 1166 times.
✓ Branch 7 taken 28308883 times.
44796792 (action==waterhold1)||(action==waterhold2)||(include_swimhit && action==swimhit)||
1750 44788854 (hopclk==0xFF));
1751 }
1752
1753 3419 void HeroClass::setDontDraw(byte new_dontdraw)
1754 {
1755 3419 dontdraw=new_dontdraw;
1756 3419 }
1757
1758 1981925 byte HeroClass::getDontDraw()
1759 {
1760 1981925 return dontdraw;
1761 }
1762
1763 3 void HeroClass::setHClk(int32_t newhclk)
1764 {
1765 3 hclk=newhclk;
1766 3 }
1767
1768 57322 int32_t HeroClass::getHClk()
1769 {
1770 57322 return hclk;
1771 }
1772
1773 11379029 int32_t HeroClass::getSpecialCave()
1774 {
1775 11379029 return specialcave; // used only by maps.cpp
1776 }
1777
1778 1549 void HeroClass::init()
1779 {
1780 1549 cache_tile_mod_clear();
1781 1549 usecounts.clear();
1782 1549 item_cooldown.fill(0);
1783 1549 scale = 0;
1784 1549 rotation = 0;
1785 1549 do_animation = true;
1786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1549 times.
1549 if(lift_wpn)
1787 {
1788 delete lift_wpn;
1789 lift_wpn = nullptr;
1790 }
1791 1549 clear_platform_ffc();
1792 1549 liftclk = 0;
1793 1549 tliftclk = 0;
1794 1549 liftheight = 0;
1795 1549 liftflags = 0;
1796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1549 times.
1549 if ( dontdraw != 2 ) { dontdraw = 0; } //scripted dontdraw == 2, normal == 1, draw hero == 0
1797 1549 hookshot_used=false;
1798 1549 justmoved = 0;
1799 1549 hookshot_frozen=false;
1800 1549 onpassivedmg=false;
1801 1549 dir = up;
1802 1549 damageovertimeclk = 0;
1803 1549 newconveyorclk = 0;
1804 1549 switchhookclk = switchhookstyle = switchhookarg = switchhookmaxtime = 0;
1805
2/2
✓ Branch 0 taken 10843 times.
✓ Branch 1 taken 1549 times.
12392 for(auto q = 0; q < 7; ++q)
1806 10843 hooked_undercombos[q] = -1;
1807 1549 shiftdir = -1;
1808 1549 sideswimdir = right;
1809 1549 holddir = -1;
1810 1549 landswim = 0;
1811 1549 sdir = up;
1812 1549 ilswim=true;
1813 1549 walkable=false;
1814 1549 moveflags = move_obeys_grav | move_can_pitfall | move_can_waterdrown;
1815 1549 warp_sound = 0;
1816 1549 subscr_speed = zinit.subscrSpeed;
1817 1549 steprate = zinit.heroStep;
1818 1549 shove_offset = zinit.shove_offset;
1819 1549 is_warping = false;
1820 1549 coyotetime = 0;
1821
1822 1549 hammer_swim_up_offset = hammeroffsets[0];
1823 1549 hammer_swim_down_offset = hammeroffsets[1];
1824 1549 hammer_swim_left_offset = hammeroffsets[2];
1825 1549 hammer_swim_right_offset = hammeroffsets[3];
1826
1827 1549 prompt_combo = prompt_x = prompt_y = prompt_cset = 0;
1828
1829
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 1137 times.
1549 if (hero_scr)
1830 {
1831
2/2
✓ Branch 0 taken 589 times.
✓ Branch 1 taken 548 times.
1137 if(get_qr(qr_NOARRIVALPOINT))
1832 {
1833 589 x=hero_scr->warpreturnx[0];
1834 589 y=hero_scr->warpreturny[0];
1835 589 }
1836 else
1837 {
1838 548 x=hero_scr->warparrivalx;
1839 548 y=hero_scr->warparrivaly;
1840 }
1841 1137 }
1842
1843 1549 z=fakez=fall=fakefall=0;
1844 1549 hzsz = 12; // So that flying peahats can still hit him.
1845
1846
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 988 times.
1549 if(x==0) dir=right;
1847
1848
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1531 times.
1549 if(x==world_w-16) dir=left;
1849
1850
2/2
✓ Branch 0 taken 570 times.
✓ Branch 1 taken 979 times.
1549 if(y==0) dir=down;
1851
1852
2/2
✓ Branch 0 taken 301 times.
✓ Branch 1 taken 1248 times.
1549 if(y==world_h-16) dir=up;
1853
1854
2/2
✓ Branch 0 taken 1137 times.
✓ Branch 1 taken 412 times.
1549 if (hero_scr)
1855 {
1856 1137 x += region_scr_dx*256;
1857 1137 y += region_scr_dy*176;
1858 1137 update_viewport();
1859 1137 }
1860
1861 1549 lstep=0;
1862 1549 skipstep=0;
1863 1549 autostep=false;
1864 1549 attackclk=holdclk=hoverclk=jumping=raftclk=0;
1865 1549 attack=wNone;
1866 1549 attackid=-1;
1867 1549 action=none; FFCore.setHeroAction(none); tempaction=none;
1868 1549 xofs=0;
1869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1549 times.
1549 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
1870 1549 cs=6;
1871 1549 flickercolor=-1;
1872 1549 flickertransp=-1;
1873 1549 pushing=fairyclk=0;
1874 1549 id=0;
1875 1549 inlikelike=0;
1876 1549 superman=inwallm=false;
1877 1549 scriptcoldet=true;
1878 1549 blowcnt=whirlwind=specialcave=0;
1879 1549 hopclk=diveclk=fallclk=0;
1880 1549 fallCombo = 0;
1881 1549 pit_pulldir = -1;
1882 1549 hopdir=-1;
1883 1549 conveyor_flags=0;
1884 1549 drunkclk=0;
1885 1549 lstunclock = 0;
1886 1549 is_conveyor_stunned=0;
1887 1549 convey_forcex=convey_forcey=0;
1888 1549 drawstyle=3;
1889 1549 ffwarp = false;
1890 1549 stepoutindex=stepoutwr=stepoutdmap=stepoutscreen=0;
1891 1549 stepnext=stepsecret=rpos_t::None;
1892 1549 ffpit = false;
1893 1549 respawn_x=x;
1894 1549 respawn_y=y;
1895 1549 respawn_dmap=cur_dmap;
1896 1549 respawn_scr=cur_screen;
1897 1549 falling_oldy = y;
1898 1549 magiccastclk=0;
1899 1549 magicitem = div_prot_item = -1;
1900 1549 last_lens_id = 0; //Should be -1 (-Z)
1901 1549 last_grav_boots_id = last_rocs_id = current_rocs_jump_id = -1;
1902 1549 released_jump_button = false;
1903 1549 last_lift_id.reset();
1904 1549 last_savepoint_id = 0;
1905 1549 misc_internal_hero_flags = 0;
1906 1549 last_cane_of_byrna_item_id = -1;
1907 1549 on_sideview_ladder = false;
1908 1549 standing_on_z = 0;
1909 1549 standing_z_offset = false;
1910 1549 extra_jump_count = 0;
1911 1549 hoverflags = 0;
1912 1549 lbunnyclock = 0;
1913 1549 lamp_paid = false;
1914 1549 autowalk_combo_id = -1;
1915 1549 autowalk_handle = {};
1916
1917
2/2
✓ Branch 0 taken 49568 times.
✓ Branch 1 taken 1549 times.
51117 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
1918
1919 1549 setBigHitbox(get_qr(qr_LTTPCOLLISION));
1920 1549 diagonalMovement=(get_qr(qr_LTTPWALK));
1921
1922 1549 shield_active = false;
1923 1549 shield_forcedir = -1;
1924 1549 active_shield_id = -1;
1925 1549 conv_forcedir = -1;
1926
1927 1549 preventsubscreenfalling = false; //-Z
1928 1549 walkspeed = 0; //not used, yet. -Z
1929
2/2
✓ Branch 0 taken 26333 times.
✓ Branch 1 taken 1549 times.
27882 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][0] = 0;
1930
2/2
✓ Branch 0 taken 26333 times.
✓ Branch 1 taken 1549 times.
27882 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) lastHitBy[q][1] = 0;
1931
2/2
✓ Branch 0 taken 226154 times.
✓ Branch 1 taken 1549 times.
227703 for ( int32_t q = 0; q < wMax; q++ )
1932 {
1933 226154 defence[q] = hero_defenses[q]; //we will need to have a Hero section in the quest load/save code! -Z Added 3/26/21 - Jman
1934 226154 }
1935
1936 1549 clear_ice();
1937 1549 script_ice_combo = 0;
1938 //Run script!
1939
4/4
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 1307 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 152 times.
1549 if (( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 ) && (game->get_hasplayed()) ) //if (!hasplayed) runs in game_loop()
1940 {
1941 90 ZScriptVersion::RunScript(ScriptType::Hero, SCRIPT_HERO_INIT);
1942 90 FFCore.deallocateAllScriptOwned(ScriptType::Hero, SCRIPT_HERO_INIT);
1943 90 FFCore.initZScriptHeroScripts(); //Clear the stack and the refinfo data to be ready for Hero's active script.
1944 90 set_respawn_point(); //screen entry at spawn; //This should be after the init script, so that Hero->X and Hero->Y set by the script
1945 //are properly set by the engine.
1946 90 }
1947 1549 FFCore.nostepforward = 0;
1948
1949
2/2
✓ Branch 0 taken 6196 times.
✓ Branch 1 taken 1549 times.
7745 for (int i = 0; i < 4; i++)
1950 6196 lastdir[i] = 0xFF;
1951
1952
2/2
✓ Branch 0 taken 319 times.
✓ Branch 1 taken 1230 times.
1549 if (replay_version_check(12))
1953 1230 z3step = 2;
1954 1549 }
1955
1956 16761451 void HeroClass::draw_under(BITMAP* dest)
1957 {
1958 16761451 int32_t c_raft=current_item_id(itype_raft);
1959 16761451 int32_t c_ladder=current_item_id(itype_ladder);
1960
1961
3/4
✓ Branch 0 taken 144426 times.
✓ Branch 1 taken 16617025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144426 times.
16761451 if(action==rafting && c_raft >-1)
1962 {
1963
4/4
✓ Branch 0 taken 106833 times.
✓ Branch 1 taken 37593 times.
✓ Branch 2 taken 82762 times.
✓ Branch 3 taken 61664 times.
144426 if(((dir==left) || (dir==right)) && (get_qr(qr_RLFIX)))
1964 {
1965 123328 overtile16(dest, itemsbuf[c_raft].tile, x - viewport.x, y+playing_field_offset+4 - viewport.y,
1966 61664 itemsbuf[c_raft].csets&15, rotate_value((itemsbuf[c_raft].misc_flags>>2)&3)^3);
1967 61664 }
1968 else
1969 {
1970 165524 overtile16(dest, itemsbuf[c_raft].tile, x - viewport.x, y+playing_field_offset+4 - viewport.y,
1971 82762 itemsbuf[c_raft].csets&15, (itemsbuf[c_raft].misc_flags>>2)&3);
1972 }
1973 144426 }
1974
1975
3/4
✓ Branch 0 taken 142297 times.
✓ Branch 1 taken 16619154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 142297 times.
16761451 if(ladderx+laddery && c_ladder >-1)
1976 {
1977
4/4
✓ Branch 0 taken 67726 times.
✓ Branch 1 taken 74571 times.
✓ Branch 2 taken 44376 times.
✓ Branch 3 taken 23350 times.
142297 if((ladderdir>=left) && (get_qr(qr_RLFIX)))
1978 {
1979 88752 overtile16(dest, itemsbuf[c_ladder].tile, ladderx - viewport.x, laddery+playing_field_offset - viewport.y,
1980 44376 itemsbuf[c_ladder].csets&15, rotate_value((itemsbuf[c_ladder].misc_flags>>2)&3)^3);
1981 44376 }
1982 else
1983 {
1984 195842 overtile16(dest, itemsbuf[c_ladder].tile, ladderx - viewport.x, laddery+playing_field_offset - viewport.y,
1985 97921 itemsbuf[c_ladder].csets&15, (itemsbuf[c_ladder].misc_flags>>2)&3);
1986 }
1987 142297 }
1988 16761451 }
1989
1990 19249 void HeroClass::drawshadow(BITMAP* dest, bool translucent)
1991 {
1992 19249 int32_t tempy=yofs;
1993 19249 yofs+=8;
1994 19249 shadowtile = wpnsbuf[spr_shadow].tile;
1995 19249 sprite::drawshadow(dest,translucent);
1996 19249 yofs=tempy;
1997 19249 }
1998
1999 // The Stone of Agony reacts to these flags.
2000 617536 bool HeroClass::agonyflag(int32_t flag)
2001 {
2002
1/2
✓ Branch 0 taken 617536 times.
✗ Branch 1 not taken.
617536 switch(flag)
2003 {
2004 case mfWHISTLE:
2005 case mfANYFIRE:
2006 case mfARROW:
2007 case mfBOMB:
2008 case mfSBOMB:
2009 case mfBRANG:
2010 case mfMBRANG:
2011 case mfFBRANG:
2012 case mfSARROW:
2013 case mfGARROW:
2014 case mfSTRONGFIRE:
2015 case mfMAGICFIRE:
2016 case mfDIVINEFIRE:
2017 case mfWANDMAGIC:
2018 case mfREFMAGIC:
2019 case mfREFFIREBALL:
2020 case mfSWORD:
2021 case mfWSWORD:
2022 case mfMSWORD:
2023 case mfXSWORD:
2024 case mfSWORDBEAM:
2025 case mfWSWORDBEAM:
2026 case mfMSWORDBEAM:
2027 case mfXSWORDBEAM:
2028 case mfHOOKSHOT:
2029 case mfWAND:
2030 case mfHAMMER:
2031 case mfSTRIKE:
2032 return true;
2033 }
2034
2035 617536 return false;
2036 617536 }
2037
2038
2039 // Find the attack power of the current melee weapon.
2040 // The Whimsical Ring is applied on a target-by-target basis.
2041 1110267 int32_t HeroClass::weaponattackpower(int32_t itid)
2042 {
2043
1/2
✓ Branch 0 taken 1110267 times.
✗ Branch 1 not taken.
1110267 if(itid < 0)
2044 {
2045 itid = current_item_id(attack==wCByrna ? itype_cbyrna
2046 : attack==wWand ? itype_wand
2047 : attack==wHammer ? itype_hammer
2048 : itype_sword);
2049 }
2050
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1110247 times.
1110267 int32_t power = attack==wCByrna ? itemsbuf[itid].misc4 : itemsbuf[itid].power;
2051
2052 // Multiply it by the power of the spin attack/quake hammer, if applicable.
2053
2/2
✓ Branch 0 taken 2189 times.
✓ Branch 1 taken 1108078 times.
1110267 if(spins > 0)
2054 {
2055 2189 int screen = currentscroll;
2056
1/2
✓ Branch 0 taken 2189 times.
✗ Branch 1 not taken.
2189 if(screen < 0)
2057 {
2058 screen = current_item_id(attack==wHammer ? (spins>1?itype_quakescroll2:itype_quakescroll)
2059 : (spins>5 || current_item_id(itype_spinscroll) < 0)
2060 ? itype_spinscroll2 : itype_spinscroll);
2061 }
2062 2189 power *= itemsbuf[screen].power;
2063 2189 }
2064 1108078 else currentscroll = -1;
2065 1110267 return power;
2066 }
2067
2068 #define NET_CLK_TOTAL 24
2069 #define NET_DIR_INC (NET_CLK_TOTAL/3)
2070 // Must only be called once per frame!
2071 138 void HeroClass::positionNet(weapon *w, int32_t itemid)
2072 {
2073 138 itemid = vbound(itemid, 0, MAXITEMS-1);
2074 138 int32_t t = w->o_tile,
2075 138 wx = 1, wy = 1;
2076
2077 //Invert positioning clock if right-handed animation
2078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 int32_t clock = (itemsbuf[itemid].flags&item_flag2 ? (NET_CLK_TOTAL-1)-attackclk : attackclk);
2079
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 if(clock >= NET_CLK_TOTAL)
2080 w->dead = 0;
2081 138 int32_t tiledir = dir;
2082
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 69 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 38 times.
138 switch(dir)
2083 {
2084 case up:
2085 {
2086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(clock < NET_DIR_INC) tiledir = l_up;
2087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if(clock >= NET_DIR_INC*2) tiledir = r_up;
2088 8 break;
2089 }
2090 case down:
2091 {
2092
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 48 times.
69 if(clock < NET_DIR_INC) tiledir = r_down;
2093
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24 times.
48 else if(clock >= NET_DIR_INC*2) tiledir = l_down;
2094 69 break;
2095 }
2096 case left:
2097 {
2098
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 16 times.
23 if(clock < NET_DIR_INC) tiledir = l_down;
2099
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 else if(clock >= NET_DIR_INC*2) tiledir = l_up;
2100 23 break;
2101 }
2102 case right:
2103 {
2104
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 24 times.
38 if(clock < NET_DIR_INC) tiledir = r_up;
2105
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
24 else if(clock >= NET_DIR_INC*2) tiledir = r_down;
2106 38 break;
2107 }
2108 }
2109 138 int32_t offs = 0;
2110
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 48 times.
138 if(tiledir > right)
2111 90 offs = ((clock%NET_DIR_INC)<NET_DIR_INC/2) ? 1 : 0;
2112 48 else offs = vbound(((clock%NET_DIR_INC)/(NET_DIR_INC/3))-1,-1,1);
2113 //One of 8 positions
2114
7/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 24 times.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 8 times.
138 switch(tiledir)
2115 {
2116 case up:
2117 {
2118 wx = 6*offs;
2119 wy = -14;
2120 break;
2121 }
2122 case r_up:
2123 {
2124 22 wx = (offs ? 10 : 14);
2125 22 wy = (offs ? -12 : -10);
2126 22 break;
2127 }
2128 case right:
2129 {
2130 16 wx = 14;
2131 16 wy = 6*offs;
2132 16 break;
2133 }
2134 case r_down:
2135 {
2136 29 wx = (offs ? 14 : 10);
2137 29 wy = (offs ? 10 : 12);
2138 29 break;
2139 }
2140 case down:
2141 {
2142 24 wx = -6*offs;
2143 24 wy = 14;
2144 24 break;
2145 }
2146 case l_down:
2147 {
2148 31 wx = (offs ? -10 : -14);
2149 31 wy = (offs ? 12 : 10);
2150 31 break;
2151 }
2152 case left:
2153 {
2154 8 wx = -14;
2155 8 wy = -6*offs;
2156 8 break;
2157 }
2158 case l_up:
2159 {
2160 8 wx = (offs ? -14 : -10);
2161 8 wy = (offs ? -10 : -12);
2162 8 break;
2163 }
2164 }
2165
2166 138 w->x = x+wx;
2167 138 w->y = y+wy-(original_playing_field_offset-2-yofs)-fakez;
2168 138 w->z = (z+zofs);
2169 138 w->fakez = fakez;
2170 138 w->tile = t+tiledir;
2171 138 w->power = 0;
2172 138 w->dir = dir;
2173 138 w->doAutoRotate(true);
2174 138 }
2175 970888 void HeroClass::positionSword(weapon *w, int32_t itemid)
2176 {
2177 //if ( w->ScriptGenerated ) return; //t/b/a for script-generated swords.
2178 //if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2179 970888 itemid=vbound(itemid, 0, MAXITEMS-1);
2180 // Place a sword weapon at the right spot.
2181 970888 int32_t wy=1;
2182 970888 int32_t wx=1;
2183 970888 int32_t f=0,t,cs2;
2184
2185 970888 t = w->o_tile;
2186 970888 cs2 = w->o_cset;
2187 970888 slashxofs=0;
2188 970888 slashyofs=0;
2189
2190
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 198027 times.
✓ Branch 2 taken 209123 times.
✓ Branch 3 taken 280583 times.
✓ Branch 4 taken 283155 times.
970888 switch(dir)
2191 {
2192 case up:
2193 198027 wx=-1;
2194 198027 wy=-12;
2195
2196
8/8
✓ Branch 0 taken 88861 times.
✓ Branch 1 taken 109166 times.
✓ Branch 2 taken 87284 times.
✓ Branch 3 taken 1577 times.
✓ Branch 4 taken 86729 times.
✓ Branch 5 taken 555 times.
✓ Branch 6 taken 8142 times.
✓ Branch 7 taken 78587 times.
198027 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2197 {
2198
2/2
✓ Branch 0 taken 50379 times.
✓ Branch 1 taken 28208 times.
78587 if(attackclk>10) //extended stab
2199 {
2200 28208 slashyofs-=3;
2201 28208 wy-=2;
2202 28208 }
2203
2204
2/2
✓ Branch 0 taken 70149 times.
✓ Branch 1 taken 8438 times.
78587 if(attackclk>=14) //retracting stab
2205 {
2206 8438 slashyofs+=3;
2207 8438 wy+=2;
2208 8438 }
2209 78587 }
2210 else
2211 {
2212
2/2
✓ Branch 0 taken 6746 times.
✓ Branch 1 taken 112694 times.
119440 if(attackclk==SWORDCHARGEFRAME)
2213 {
2214 6746 wy+=4;
2215 6746 }
2216
2/2
✓ Branch 0 taken 10921 times.
✓ Branch 1 taken 101773 times.
112694 else if(attackclk==13)
2217 {
2218 10921 wy+=4;
2219 10921 }
2220
2/2
✓ Branch 0 taken 90960 times.
✓ Branch 1 taken 10813 times.
101773 else if(attackclk==14)
2221 {
2222 10813 wy+=8;
2223 10813 }
2224 }
2225
2226 198027 break;
2227
2228 case down:
2229 209123 f=get_qr(qr_SWORDWANDFLIPFIX)?3:2;
2230 209123 wy=11;
2231
2232
8/8
✓ Branch 0 taken 112256 times.
✓ Branch 1 taken 96867 times.
✓ Branch 2 taken 110853 times.
✓ Branch 3 taken 1403 times.
✓ Branch 4 taken 110141 times.
✓ Branch 5 taken 712 times.
✓ Branch 6 taken 6988 times.
✓ Branch 7 taken 103153 times.
209123 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2233 {
2234
2/2
✓ Branch 0 taken 64900 times.
✓ Branch 1 taken 38253 times.
103153 if(attackclk>10) //extended stab
2235 {
2236 38253 slashyofs+=3;
2237 38253 wy+=2;
2238 38253 }
2239
2240
2/2
✓ Branch 0 taken 91566 times.
✓ Branch 1 taken 11587 times.
103153 if(attackclk>=14) //retracting stab
2241 {
2242 11587 slashyofs-=3;
2243 11587 wy-=2;
2244 11587 }
2245 103153 }
2246 else
2247 {
2248
2/2
✓ Branch 0 taken 6473 times.
✓ Branch 1 taken 99497 times.
105970 if(attackclk==SWORDCHARGEFRAME)
2249 {
2250 6473 wy-=2;
2251 6473 }
2252
2/2
✓ Branch 0 taken 9902 times.
✓ Branch 1 taken 89595 times.
99497 else if(attackclk==13)
2253 {
2254 9902 wy-=4;
2255 9902 }
2256
2/2
✓ Branch 0 taken 79728 times.
✓ Branch 1 taken 9867 times.
89595 else if(attackclk==14)
2257 {
2258 9867 wy-=8;
2259 9867 }
2260 }
2261
2262 209123 break;
2263
2264 case left:
2265 280583 f=1;
2266 280583 wx=-11;
2267 280583 ++t;
2268
2269
8/8
✓ Branch 0 taken 159182 times.
✓ Branch 1 taken 121401 times.
✓ Branch 2 taken 155483 times.
✓ Branch 3 taken 3699 times.
✓ Branch 4 taken 154036 times.
✓ Branch 5 taken 1447 times.
✓ Branch 6 taken 10065 times.
✓ Branch 7 taken 143971 times.
280583 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2270 {
2271
2/2
✓ Branch 0 taken 89622 times.
✓ Branch 1 taken 54349 times.
143971 if(attackclk>10) //extended stab
2272 {
2273 54349 slashxofs-=4;
2274 54349 wx-=7;
2275 54349 }
2276
2277
2/2
✓ Branch 0 taken 128009 times.
✓ Branch 1 taken 15962 times.
143971 if(attackclk>=14) //retracting stab
2278 {
2279 15962 slashxofs+=3;
2280 15962 wx+=7;
2281 15962 }
2282 143971 }
2283 else
2284 {
2285
2/2
✓ Branch 0 taken 8752 times.
✓ Branch 1 taken 127860 times.
136612 if(attackclk==SWORDCHARGEFRAME)
2286 {
2287 8752 wx+=2;
2288 8752 }
2289
2/2
✓ Branch 0 taken 12715 times.
✓ Branch 1 taken 115145 times.
127860 else if(attackclk==13)
2290 {
2291 12715 wx+=4;
2292 12715 }
2293
2/2
✓ Branch 0 taken 102473 times.
✓ Branch 1 taken 12672 times.
115145 else if(attackclk==14)
2294 {
2295 12672 wx+=8;
2296 12672 }
2297 }
2298
2299 280583 break;
2300
2301 case right:
2302 283155 wx=11;
2303 283155 ++t;
2304
2305
8/8
✓ Branch 0 taken 155482 times.
✓ Branch 1 taken 127673 times.
✓ Branch 2 taken 152680 times.
✓ Branch 3 taken 2802 times.
✓ Branch 4 taken 149384 times.
✓ Branch 5 taken 3296 times.
✓ Branch 6 taken 13666 times.
✓ Branch 7 taken 135718 times.
283155 if(game->get_canslash() && w->id==wSword && itemsbuf[itemid].flags & item_flag4 && charging==0)
2306 {
2307
2/2
✓ Branch 0 taken 84139 times.
✓ Branch 1 taken 51579 times.
135718 if(attackclk>10) //extended stab
2308 {
2309 51579 slashxofs+=4;
2310 51579 wx+=7;
2311 51579 }
2312
2313
2/2
✓ Branch 0 taken 120013 times.
✓ Branch 1 taken 15705 times.
135718 if(attackclk>=14) //retracting stab
2314 {
2315 15705 slashxofs-=3;
2316 15705 wx-=7;
2317 15705 }
2318 135718 }
2319 else
2320 {
2321
2/2
✓ Branch 0 taken 12322 times.
✓ Branch 1 taken 135115 times.
147437 if(attackclk==SWORDCHARGEFRAME)
2322 {
2323 12322 wx-=2;
2324 12322 }
2325
2/2
✓ Branch 0 taken 13394 times.
✓ Branch 1 taken 121721 times.
135115 else if(attackclk==13)
2326 {
2327 13394 wx-=4;
2328 13394 }
2329
2/2
✓ Branch 0 taken 108365 times.
✓ Branch 1 taken 13356 times.
121721 else if(attackclk==14)
2330 {
2331 13356 wx-=8;
2332 13356 }
2333 }
2334
2335 283155 break;
2336 }
2337
2338
6/6
✓ Branch 0 taken 515781 times.
✓ Branch 1 taken 455107 times.
✓ Branch 2 taken 503076 times.
✓ Branch 3 taken 12705 times.
✓ Branch 4 taken 212239 times.
✓ Branch 5 taken 290837 times.
970888 if(game->get_canslash() && itemsbuf[itemid].flags & item_flag4 && attackclk<11)
2339 {
2340 290837 int32_t wpn2=itemsbuf[itemid].wpn2;
2341 290837 wpn2=vbound(wpn2, 0, MAXWPNS);
2342
2343 //slashing tiles
2344
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 50664 times.
✓ Branch 2 taken 65294 times.
✓ Branch 3 taken 90255 times.
✓ Branch 4 taken 84624 times.
290837 switch(dir)
2345 {
2346 case up:
2347 50664 wx=15;
2348 50664 wy=-3;
2349 50664 ++t;
2350 50664 f=0; //starts pointing right
2351
2352
2/2
✓ Branch 0 taken 22596 times.
✓ Branch 1 taken 28068 times.
50664 if(attackclk>=7)
2353 {
2354 28068 wy-=9;
2355 28068 wx-=3;
2356 28068 t = wpnsbuf[wpn2].tile;
2357 28068 cs2 = wpnsbuf[wpn2].csets&15;
2358 28068 f=0;
2359 28068 }
2360
2361 50664 break;
2362
2363 case down:
2364 65294 wx=-13;
2365 65294 wy=-1;
2366 65294 ++t;
2367 65294 f=1; //starts pointing left
2368
2369
2/2
✓ Branch 0 taken 28500 times.
✓ Branch 1 taken 36794 times.
65294 if(attackclk>=7)
2370 {
2371 36794 wy+=15;
2372 36794 wx+=2;
2373 36794 t = wpnsbuf[wpn2].tile;
2374 36794 cs2 = wpnsbuf[wpn2].csets&15;
2375 36794 ++t;
2376 36794 f=0;
2377 36794 }
2378
2379 65294 break;
2380
2381 case left:
2382 90255 wx=3;
2383 90255 wy=-15;
2384 90255 --t;
2385 90255 f=0; //starts pointing up
2386
2387
2/2
✓ Branch 0 taken 38484 times.
✓ Branch 1 taken 51771 times.
90255 if(attackclk>=7)
2388 {
2389 51771 wx-=15;
2390 51771 wy+=3;
2391 51771 slashxofs-=1;
2392 51771 t = wpnsbuf[wpn2].tile;
2393 51771 cs2 = wpnsbuf[wpn2].csets&15;
2394 51771 t+=2;
2395 51771 f=0;
2396 51771 }
2397
2398 90255 break;
2399
2400 case right:
2401 84624 --t;
2402
2403
3/4
✓ Branch 0 taken 84211 times.
✓ Branch 1 taken 413 times.
✓ Branch 2 taken 84211 times.
✗ Branch 3 not taken.
84624 if(spins>0 || (itemsbuf[itemid].flags & item_flag8))
2404 {
2405 413 wx=1;
2406 413 wy=13;
2407 413 f=2;
2408 413 }
2409 else
2410 {
2411 84211 wx=3;
2412 84211 wy=-15;
2413 84211 f=0;
2414 }
2415
2416
2/2
✓ Branch 0 taken 36128 times.
✓ Branch 1 taken 48496 times.
84624 if(attackclk>=7)
2417 {
2418 48496 wx+=15;
2419 48496 slashxofs+=1;
2420 48496 t = wpnsbuf[wpn2].tile;
2421 48496 cs2 = wpnsbuf[wpn2].csets&15;
2422
2423
3/4
✓ Branch 0 taken 48221 times.
✓ Branch 1 taken 275 times.
✓ Branch 2 taken 48221 times.
✗ Branch 3 not taken.
48496 if(spins>0 || (itemsbuf[itemid].flags & item_flag8))
2424 {
2425 275 wx-=1;
2426 275 wy-=2;
2427 275 }
2428 else
2429 {
2430 48221 t+=3;
2431 48221 f=0;
2432 48221 wy+=3;
2433 }
2434 48496 }
2435
2436 84624 break;
2437 }
2438 290837 }
2439
2440 970888 int32_t itemid2 = current_item_id(itype_chargering);
2441
2442
4/4
✓ Branch 0 taken 28541 times.
✓ Branch 1 taken 942347 times.
✓ Branch 2 taken 957767 times.
✓ Branch 3 taken 13121 times.
970888 if(charging>(itemid2>=0 ? itemsbuf[itemid2].misc1 : 64))
2443 {
2444
2/2
✓ Branch 0 taken 12589 times.
✓ Branch 1 taken 532 times.
13121 cs2=(BSZ ? (frame&3)+6 : ((frame>>2)&1)+7);
2445 13121 }
2446
2447 970888 w->x = x+wx;
2448 970888 w->y = y+wy-(original_playing_field_offset-2-(yofs+slashyofs))-fakez;
2449 970888 w->z = (z+zofs);
2450 970888 w->tile = t;
2451 970888 w->flip = f;
2452 970888 w->power = weaponattackpower(itemid);
2453 970888 w->dir = dir;
2454 970888 w->doAutoRotate(true);
2455 970888 }
2456
2457 int HeroClass::getHammerState() const
2458 {
2459 if(attack == wHammer)
2460 {
2461 if(attackclk >= 15)
2462 return 3;
2463 if(attackclk >= 13)
2464 return 2;
2465 return 1;
2466 }
2467 return 0;
2468 }
2469 1101524 weapon* find_first_wtype(int wtype)
2470 {
2471
2/2
✓ Branch 0 taken 1184951 times.
✓ Branch 1 taken 89358 times.
1274309 for(int32_t i=0; i<Lwpns.Count(); i++)
2472 {
2473 1184951 weapon* w = (weapon*)Lwpns.spr(i);
2474
2475
2/2
✓ Branch 0 taken 1012166 times.
✓ Branch 1 taken 172785 times.
1184951 if(w->id == wtype)
2476 1012166 return w;
2477 172785 }
2478 89358 return nullptr;
2479 1101524 }
2480 16890990 void HeroClass::draw(BITMAP* dest)
2481 {
2482 16890990 int32_t oxofs = xofs, oyofs = yofs;
2483
2/2
✓ Branch 0 taken 94966 times.
✓ Branch 1 taken 16796024 times.
16890990 bool invisible=(dontdraw>0) || (hero_scr->flags3&fINVISHERO);
2484
2485 {
2486
2/2
✓ Branch 0 taken 16957 times.
✓ Branch 1 taken 16874033 times.
16890990 if(action==dying)
2487 {
2488
2/2
✓ Branch 0 taken 12844 times.
✓ Branch 1 taken 4113 times.
16957 if(!invisible)
2489 {
2490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4113 times.
4113 if ( script_hero_cset > -1 ) cs = script_hero_cset;
2491 4113 sprite::draw(dest);
2492 4113 }
2493 16957 goto herodraw_end;
2494 }
2495
2496 16874033 bool useltm=(get_qr(qr_EXPANDEDLTM) != 0);
2497
2498
2499
2/2
✓ Branch 0 taken 278644 times.
✓ Branch 1 taken 16595389 times.
16874033 if(!invisible)
2500
6/6
✓ Branch 0 taken 7414945 times.
✓ Branch 1 taken 9180444 times.
✓ Branch 2 taken 4809023 times.
✓ Branch 3 taken 2605922 times.
✓ Branch 4 taken 183822 times.
✓ Branch 5 taken 4625201 times.
16595389 yofs = oyofs-((!BSZ && isdungeon() && cur_screen<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
2501
2502 // Stone of Agony
2503 16874033 bool agony=false;
2504 16874033 int32_t agonyid = current_item_id(itype_agony);
2505
2506
2/2
✓ Branch 0 taken 278644 times.
✓ Branch 1 taken 16595389 times.
16874033 if(!invisible)
2507 {
2508
2/2
✓ Branch 0 taken 308768 times.
✓ Branch 1 taken 16286621 times.
16595389 if(agonyid>-1)
2509 {
2510 308768 int32_t power=itemsbuf[agonyid].power;
2511 308768 int32_t left=static_cast<int32_t>(x+8-power)&0xF0; // Check top-left pixel of each tile
2512 308768 int32_t right=(static_cast<int32_t>(x+8+power)&0xF0)+16;
2513 308768 int32_t top=static_cast<int32_t>(y+(bigHitbox ? 8 : 12)-power)&0xF0;
2514 308768 int32_t bottom=(static_cast<int32_t>(y+(bigHitbox ? 8 : 12)+power)&0xF0)+16;
2515
2516
2/2
✓ Branch 0 taken 308768 times.
✓ Branch 1 taken 308768 times.
617536 for(int32_t x=left; x<right; x+=16)
2517 {
2518
2/2
✓ Branch 0 taken 308768 times.
✓ Branch 1 taken 308768 times.
617536 for(int32_t y=top; y<bottom; y+=16)
2519 {
2520
2/4
✓ Branch 0 taken 308768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 308768 times.
✗ Branch 3 not taken.
308768 if(agonyflag(MAPFLAG(x, y)) || agonyflag(MAPCOMBOFLAG(x, y)))
2521 {
2522 agony=true;
2523 x=right; // Break out of outer loop
2524 break;
2525 }
2526 308768 }
2527 308768 }
2528 308768 }
2529
2530 16595389 cs = getFlashingCSet();
2531 16595389 }
2532
2533
5/6
✓ Branch 0 taken 15133481 times.
✓ Branch 1 taken 1740552 times.
✓ Branch 2 taken 15120212 times.
✓ Branch 3 taken 13269 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15120212 times.
16874033 if(attackclk || (action==attacking||action==sideswimattacking))
2534 {
2535 /* Spaghetti code constants!
2536 * - Hero.attack contains a weapon type...
2537 * - which must be converted to an itype...
2538 * - which must be converted to an item ID...
2539 * - which is used to acquire a wpn ID! Aack!
2540 */
2541
8/8
✓ Branch 0 taken 38963 times.
✓ Branch 1 taken 1714858 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 1714830 times.
✓ Branch 4 taken 25729 times.
✓ Branch 5 taken 1689101 times.
✓ Branch 6 taken 64669 times.
✓ Branch 7 taken 1624432 times.
1753821 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : attack==wBugNet ? itype_bugnet : itype_sword);
2542
4/4
✓ Branch 0 taken 493821 times.
✓ Branch 1 taken 1199064 times.
✓ Branch 2 taken 324952 times.
✓ Branch 3 taken 168869 times.
1753821 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
2543 1692885 itemid=vbound(itemid, 0, MAXITEMS-1);
2544 // if ( itemsbuf[itemid].ScriptGenerated ) return; //t/b/a for script-generated swords.
2545
8/8
✓ Branch 0 taken 577194 times.
✓ Branch 1 taken 1115691 times.
✓ Branch 2 taken 577170 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 380383 times.
✓ Branch 5 taken 196787 times.
✓ Branch 6 taken 215914 times.
✓ Branch 7 taken 164469 times.
1692885 if(attackclk>4||attack==wBugNet||(attack==wSword&&game->get_canslash()))
2546 {
2547
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1331491 times.
1331629 if(attack == wBugNet)
2548 {
2549 138 weapon *w=NULL;
2550 138 bool found = false;
2551
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 132 times.
138 for(int32_t q = 0; q < Lwpns.Count(); ++q)
2552 {
2553 132 w = (weapon*)Lwpns.spr(q);
2554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(w->id == wBugNet)
2555 {
2556 132 found = true;
2557 132 break;
2558 }
2559 }
2560
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 6 times.
138 if(!found)
2561 {
2562 // TODO(crash): check that .add succeeds.
2563
5/10
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
6 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wBugNet,0,0,dir,itemid,getUID(),false,false,true));
2564
2565 6 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2566 6 }
2567 138 positionNet(w, itemid);
2568 138 }
2569
8/8
✓ Branch 0 taken 248832 times.
✓ Branch 1 taken 1082659 times.
✓ Branch 2 taken 230458 times.
✓ Branch 3 taken 18374 times.
✓ Branch 4 taken 215664 times.
✓ Branch 5 taken 14794 times.
✓ Branch 6 taken 229968 times.
✓ Branch 7 taken 1101523 times.
1331491 else if((attack==wSword || attack==wWand || ((attack==wFire || attack==wCByrna) && itemsbuf[itemid].wpn)) && wpnsbuf[itemsbuf[itemid].wpn].tile)
2570 {
2571 // Create a sword weapon at the right spot.
2572 1101523 weapon *w=find_first_wtype(attack==wSword ? wSword : wWand);
2573
2/2
✓ Branch 0 taken 1012165 times.
✓ Branch 1 taken 89358 times.
1101523 if(!w) // Create one if sword nonexistant
2574 {
2575
5/10
✓ Branch 0 taken 89358 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89358 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89358 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89358 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 89358 times.
✗ Branch 9 not taken.
89358 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,(attack==wSword ? wSword : wWand),0,0,dir,itemid,getUID(),false,false,true));
2576 89358 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2577
2578 89358 positionSword(w,itemid);
2579
2580 // Stone of Agony
2581
1/2
✓ Branch 0 taken 89358 times.
✗ Branch 1 not taken.
89358 if(agony)
2582 {
2583 w->y-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,2))?1:0;
2584 }
2585 89358 }
2586
2587 // These are set by positionSword(), above or in checkstab()
2588 1101523 yofs += slashyofs;
2589 1101523 xofs += slashxofs;
2590 1101523 slashyofs = slashxofs = 0;
2591 1101523 }
2592 1331629 }
2593
2594 1692987 if(attackclk<7
2595
4/4
✓ Branch 0 taken 921785 times.
✓ Branch 1 taken 771100 times.
✓ Branch 2 taken 735714 times.
✓ Branch 3 taken 186071 times.
1692885 || (attack==wSword && ((attackclk<(game->get_canslash()?15:13)
2596
4/6
✓ Branch 0 taken 137324 times.
✓ Branch 1 taken 598390 times.
✓ Branch 2 taken 137324 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 137324 times.
735714 || FIXED_Z3_ANIMATION && attackclk<(game->get_canslash()?16:12))
2597
2/2
✓ Branch 0 taken 38044 times.
✓ Branch 1 taken 99280 times.
137324 || (charging>0 && attackclk!=SWORDCHARGEFRAME)))
2598
4/4
✓ Branch 0 taken 304556 times.
✓ Branch 1 taken 24229 times.
✓ Branch 2 taken 293092 times.
✓ Branch 3 taken 11464 times.
323395 || ((attack==wWand || attack==wFire || attack==wCByrna) && attackclk<13)
2599
4/4
✓ Branch 0 taken 29461 times.
✓ Branch 1 taken 299324 times.
✓ Branch 2 taken 50971 times.
✓ Branch 3 taken 248353 times.
328785 || (attack==wHammer && attackclk<=30)
2600
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 248251 times.
299324 || (attack==wBugNet && attackclk<NET_CLK_TOTAL))
2601 {
2602
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 1487728 times.
1488068 if(!invisible)
2603 {
2604 1487728 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimstab:ls_stab, dir, zinit.heroAnimationStyle);
2605
2/4
✓ Branch 0 taken 1487728 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487728 times.
✗ Branch 3 not taken.
1487728 if (FIXED_Z3_ANIMATION)
2606 {
2607 if (attackclk >= 2) tile += (extend==2?2:1);
2608 if (attackclk >= 13) tile += (extend==2?2:1);
2609 }
2610
2611
14/18
✓ Branch 0 taken 750280 times.
✓ Branch 1 taken 737448 times.
✓ Branch 2 taken 157640 times.
✓ Branch 3 taken 592640 times.
✓ Branch 4 taken 146759 times.
✓ Branch 5 taken 10881 times.
✓ Branch 6 taken 142255 times.
✓ Branch 7 taken 4504 times.
✓ Branch 8 taken 588309 times.
✓ Branch 9 taken 161971 times.
✓ Branch 10 taken 333492 times.
✓ Branch 11 taken 254817 times.
✓ Branch 12 taken 333492 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 333492 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
1487728 if(((game->get_canslash() && (attack==wSword || attack==wWand || attack==wFire || attack==wCByrna)) && itemsbuf[itemid].flags&item_flag4 && (attackclk<7||FIXED_Z3_ANIMATION&&(attackclk < 16))))
2612 {
2613 254817 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2614
2/4
✓ Branch 0 taken 254817 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 254817 times.
✗ Branch 3 not taken.
254817 if (FIXED_Z3_ANIMATION)
2615 {
2616 if (attackclk >= 7) tile += (extend==2?2:1);
2617 if (attackclk >= 11) tile += (extend==2?2:1);
2618 if (attackclk >= 14) tile += (extend==2?2:1);
2619 }
2620 254817 }
2621
3/4
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 1487590 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 138 times.
1487728 if (attack==wBugNet && !get_qr(qr_OLD_BUG_NET))
2622 {
2623
6/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 62 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 62 times.
138 if ((dir == right && (itemsbuf[itemid].flags&item_flag2)) || (dir != right && !(itemsbuf[itemid].flags&item_flag2)))
2624 {
2625
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 32 times.
100 if (attackclk < 9) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2626
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 40 times.
100 if (attackclk > 15) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2627 100 }
2628 else
2629 {
2630
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 16 times.
162 if (attackclk < 9) herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimslash:ls_slash, dir, zinit.heroAnimationStyle);
2631
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 8 times.
38 if (attackclk > 15) herotile(&tile, &flip, &extend, ls_revslash, dir, zinit.heroAnimationStyle);
2632 }
2633 138 }
2634
2635
4/4
✓ Branch 0 taken 64669 times.
✓ Branch 1 taken 1423059 times.
✓ Branch 2 taken 37763 times.
✓ Branch 3 taken 26906 times.
1487728 if((attack==wHammer) && (attackclk<13))
2636 {
2637 26906 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimpound:ls_pound, dir, zinit.heroAnimationStyle);
2638
2/4
✓ Branch 0 taken 26906 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26906 times.
✗ Branch 3 not taken.
26906 if (FIXED_Z3_ANIMATION)
2639 {
2640 if (attackclk >= 14) tile += (extend==2?2:1);
2641 if (attackclk >= 16) tile += (extend==2?2:1);
2642 }
2643 26906 }
2644
2645
2/2
✓ Branch 0 taken 987175 times.
✓ Branch 1 taken 500553 times.
1487728 if(useltm)
2646 {
2647
2/2
✓ Branch 0 taken 1885 times.
✓ Branch 1 taken 498668 times.
500553 if ( script_hero_sprite <= 0 ) tile+=getTileModifier();
2648 500553 }
2649
2650 // Stone of Agony
2651
1/2
✓ Branch 0 taken 1487728 times.
✗ Branch 1 not taken.
1487728 if(agony)
2652 {
2653 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2654 }
2655
2656 //Probably what makes Hero flicker, except for the QR check. What makes him flicker when that rule is off?! -Z
2657
2658 //I'm pretty sure he doesn't flicker when the rule is off. Also, take note of the parenthesis after the ! in this if statement; I was blind and didn't see it, and thought this code did something completely different. -Deedee
2659
2/2
✓ Branch 0 taken 12487 times.
✓ Branch 1 taken 1475241 times.
1487728 if (is_hitflickerframe())
2660 {
2661
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12485 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12485 times.
12487 int32_t temp_flicker_color = (game->get_life() > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
2662
2/4
✓ Branch 0 taken 12487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12487 times.
✗ Branch 3 not taken.
12487 if((game->get_spriteflickercolor() || temp_flicker_color) && !superman)
2663 {
2664 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
2665 sprite_flicker_color = temp_flicker_color;
2666 masked_draw(dest);
2667 }
2668 12487 }
2669 else
2670 1475241 masked_draw(dest);
2671
2672 //Prevent flickering -Z
2673
1/2
✓ Branch 0 taken 1487728 times.
✗ Branch 1 not taken.
1487728 if (!getCanFlicker()) masked_draw(dest);
2674 1487728 }
2675
2676
2/2
✓ Branch 0 taken 1423399 times.
✓ Branch 1 taken 64669 times.
1488068 if(attack!=wHammer)
2677 1423399 goto herodraw_end;
2678 64669 }
2679
2680
2/2
✓ Branch 0 taken 64669 times.
✓ Branch 1 taken 248251 times.
312920 if(attack==wHammer) // To do: possibly abstract this out to a positionHammer routine?
2681 {
2682 64669 int32_t wy=1;
2683 64669 int32_t wx=1;
2684 64669 int32_t f=0,t,cs2;
2685 64669 weapon *w=NULL;
2686 64669 bool found = false;
2687
2688
2/2
✓ Branch 0 taken 2257 times.
✓ Branch 1 taken 63298 times.
65555 for(int32_t i=0; i<Lwpns.Count(); i++)
2689 {
2690 63298 w = (weapon*)Lwpns.spr(i);
2691
2692
2/2
✓ Branch 0 taken 886 times.
✓ Branch 1 taken 62412 times.
63298 if(w->id == wHammer)
2693 {
2694 62412 found = true;
2695 62412 break;
2696 }
2697 886 }
2698
2699
2/2
✓ Branch 0 taken 62412 times.
✓ Branch 1 taken 2257 times.
64669 if(!found)
2700 {
2701
5/10
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2257 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2257 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2257 times.
✗ Branch 9 not taken.
2257 Lwpns.add(new weapon((zfix)0,(zfix)0,(zfix)0,wHammer,0,0,dir,itemid,getUID(),false,false,true));
2702 2257 w = (weapon*)Lwpns.spr(Lwpns.Count()-1);
2703 2257 found = true;
2704 2257 }
2705
2706 64669 t = w->o_tile;
2707 64669 cs2 = w->o_cset;
2708
2709
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 10368 times.
✓ Branch 2 taken 15134 times.
✓ Branch 3 taken 21186 times.
✓ Branch 4 taken 17981 times.
64669 switch(dir)
2710 {
2711 case up:
2712 10368 wx=-1;
2713 10368 wy=-15;
2714
1/2
✓ Branch 0 taken 10368 times.
✗ Branch 1 not taken.
10368 if (IsSideSwim())wy+=hammer_swim_up_offset;
2715
2716
2/2
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 5985 times.
10368 if(attackclk>=13)
2717 {
2718 5985 wx-=1;
2719 5985 wy+=1;
2720 5985 ++t;
2721 5985 }
2722
2723
2/2
✓ Branch 0 taken 5061 times.
✓ Branch 1 taken 5307 times.
10368 if(attackclk>=15)
2724 {
2725
1/2
✓ Branch 0 taken 5307 times.
✗ Branch 1 not taken.
5307 if (IsSideSwim())wy-=hammer_swim_up_offset;
2726 5307 ++t;
2727 5307 }
2728
2729 10368 break;
2730
2731 case down:
2732 15134 wx=3;
2733 15134 wy=-14;
2734
1/2
✓ Branch 0 taken 15134 times.
✗ Branch 1 not taken.
15134 if (IsSideSwim())wy+=hammer_swim_down_offset;
2735 15134 t+=3;
2736
2737
2/2
✓ Branch 0 taken 6339 times.
✓ Branch 1 taken 8795 times.
15134 if(attackclk>=13)
2738 {
2739 8795 wy+=16;
2740 8795 ++t;
2741 8795 }
2742
2743
2/2
✓ Branch 0 taken 7346 times.
✓ Branch 1 taken 7788 times.
15134 if(attackclk>=15)
2744 {
2745 7788 wx-=1;
2746 7788 wy+=12;
2747
1/2
✓ Branch 0 taken 7788 times.
✗ Branch 1 not taken.
7788 if (IsSideSwim())wy-=hammer_swim_down_offset;
2748 7788 ++t;
2749 7788 }
2750
2751 15134 break;
2752
2753 case left:
2754 21186 wx=0;
2755 21186 wy=-14;
2756
1/2
✓ Branch 0 taken 21186 times.
✗ Branch 1 not taken.
21186 if (IsSideSwim())wy+=hammer_swim_left_offset;
2757 21186 t+=6;
2758 21186 f=1;
2759
2760
2/2
✓ Branch 0 taken 8801 times.
✓ Branch 1 taken 12385 times.
21186 if(attackclk>=13)
2761 {
2762 12385 wx-=7;
2763 12385 wy+=8;
2764 12385 ++t;
2765 12385 }
2766
2767
2/2
✓ Branch 0 taken 10219 times.
✓ Branch 1 taken 10967 times.
21186 if(attackclk>=15)
2768 {
2769 10967 wx-=8;
2770 10967 wy+=8;
2771
1/2
✓ Branch 0 taken 10967 times.
✗ Branch 1 not taken.
10967 if (IsSideSwim())wy-=hammer_swim_left_offset;
2772 10967 ++t;
2773 10967 }
2774
2775 21186 break;
2776
2777 case right:
2778 17981 wx=0;
2779 17981 wy=-14;
2780
1/2
✓ Branch 0 taken 17981 times.
✗ Branch 1 not taken.
17981 if (IsSideSwim())wy+=hammer_swim_right_offset;
2781 17981 t+=6;
2782
2783
2/2
✓ Branch 0 taken 7383 times.
✓ Branch 1 taken 10598 times.
17981 if(attackclk>=13)
2784 {
2785 10598 wx+=7;
2786 10598 wy+=8;
2787 10598 ++t;
2788 10598 }
2789
2790
2/2
✓ Branch 0 taken 8581 times.
✓ Branch 1 taken 9400 times.
17981 if(attackclk>=15)
2791 {
2792 9400 wx+=8;
2793 9400 wy+=8;
2794
1/2
✓ Branch 0 taken 9400 times.
✗ Branch 1 not taken.
9400 if (IsSideSwim())wy-=hammer_swim_right_offset;
2795 9400 ++t;
2796 9400 }
2797
2798 17981 break;
2799 }
2800
2801
7/8
✓ Branch 0 taken 28062 times.
✓ Branch 1 taken 36607 times.
✓ Branch 2 taken 20878 times.
✓ Branch 3 taken 7184 times.
✓ Branch 4 taken 20878 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4720 times.
✓ Branch 7 taken 16158 times.
64669 if(BSZ || ((isdungeon() && cur_screen<128) && !get_qr(qr_HERODUNGEONPOSFIX)))
2802 {
2803 52765 wy+=2;
2804 52765 }
2805
2806 // Stone of Agony
2807
1/2
✓ Branch 0 taken 64669 times.
✗ Branch 1 not taken.
64669 if(agony)
2808 {
2809 wy-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
2810 }
2811
2812 64669 w->x = x+wx;
2813 64669 w->y = y+wy-(original_playing_field_offset-2-yofs)-fakez;
2814 64669 w->z = (z+zofs);
2815 64669 w->tile = t;
2816 64669 w->flip = f;
2817 64669 w->hit_width=20;
2818 64669 w->hit_height=20;
2819
2820
2/2
✓ Branch 0 taken 39167 times.
✓ Branch 1 taken 25502 times.
64669 if(dir>down)
2821 {
2822 39167 w->hit_height-=6;
2823 39167 }
2824 else
2825 {
2826 25502 w->hit_width-=6;
2827 25502 w->hyofs=4;
2828 }
2829
2830 64669 w->power = weaponattackpower(itemid);
2831
2832
7/10
✓ Branch 0 taken 2132 times.
✓ Branch 1 taken 62537 times.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2132 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2127 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
64669 if(attackclk==15 && z==0 && fakez==0 && (sideviewhammerpound() || !isSideViewHero()))
2833 {
2834
3/4
✓ Branch 0 taken 2120 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2132 times.
✗ Branch 3 not taken.
2132 sfx(((iswaterex_z3(MAPCOMBO(x+wx+8,y+wy), -1, x+wx+8, y+wy, true) || COMBOTYPE(x+wx+8,y+wy)==cSHALLOWWATER) && get_qr(qr_MORESOUNDS)) ? WAV_ZN1SPLASH : itemsbuf[itemid].usesound,pan(x));
2835 2132 }
2836
2837 64669 goto herodraw_end;
2838 }
2839 248251 }
2840
2/4
✓ Branch 0 taken 15120212 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15120212 times.
15120212 else if(!charging && !spins) // remove the sword
2841 {
2842
2/2
✓ Branch 0 taken 2967273 times.
✓ Branch 1 taken 15120212 times.
18087485 for(int32_t i=0; i<Lwpns.Count(); i++)
2843 {
2844 2967273 weapon *w = (weapon*)Lwpns.spr(i);
2845
2846
6/6
✓ Branch 0 taken 2966376 times.
✓ Branch 1 taken 897 times.
✓ Branch 2 taken 2964868 times.
✓ Branch 3 taken 1508 times.
✓ Branch 4 taken 31846 times.
✓ Branch 5 taken 2933022 times.
2967273 if(w->id == wSword || w->id == wHammer || w->id==wWand)
2847 34251 w->dead=1;
2848 2967273 }
2849 15120212 }
2850
2851
2/2
✓ Branch 0 taken 260802 times.
✓ Branch 1 taken 15107661 times.
15368463 if(invisible)
2852 {
2853 260802 goto herodraw_end;
2854 }
2855
2856
3/4
✓ Branch 0 taken 15104814 times.
✓ Branch 1 taken 2847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15104814 times.
15107661 if(action != casting && action != sideswimcasting)
2857 {
2858 // Keep this consistent with checkspecial2, line 7800-ish...
2859
6/6
✓ Branch 0 taken 295622 times.
✓ Branch 1 taken 14809192 times.
✓ Branch 2 taken 285645 times.
✓ Branch 3 taken 9977 times.
✓ Branch 4 taken 10634 times.
✓ Branch 5 taken 275011 times.
15104814 bool inwater = iswaterex_z3(MAPCOMBO(x+4,y+9), -1, x+4, y+9, true, false) && iswaterex_z3(MAPCOMBO(x+4,y+15), -1, x+4, y+15, true, false) && iswaterex_z3(MAPCOMBO(x+11,y+9), -1, x+11, y+9, true, false) && iswaterex_z3(MAPCOMBO(x+11,y+15), -1, x+11, y+15, true, false);
2860
2861 15104814 optional<uint32_t> jumping_frame;
2862
2863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15104814 times.
15104814 if (get_qr(qr_BETTER_PLAYER_JUMP_ANIM))
2864 {
2865 if (jumping && fall)
2866 jumping_frame = (jumping / 6) % 3;
2867 }
2868 else
2869 {
2870 15104814 auto val = int32_t(jumping * (get_grav_fall() / 16.0));
2871
4/4
✓ Branch 0 taken 128004 times.
✓ Branch 1 taken 14976810 times.
✓ Branch 2 taken 25444 times.
✓ Branch 3 taken 102560 times.
15104814 if (val > 0 && val < 24)
2872 102560 jumping_frame = val / 8;
2873 }
2874
2875 15104814 bool noliftspr = get_qr(qr_NO_LIFT_SPRITE);
2876 15104814 bool advancetile = script_hero_sprite <= 0;
2877
2/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 8530311 times.
✓ Branch 3 taken 6574503 times.
15104814 switch(zinit.heroAnimationStyle)
2878 {
2879 case las_original: //normal
2880
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 8527143 times.
8530311 if(action==drowning)
2881 {
2882
1/2
✓ Branch 0 taken 3168 times.
✗ Branch 1 not taken.
3168 if(inwater)
2883 {
2884 3168 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
2885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3168 times.
3168 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2886 3168 }
2887 else
2888 {
2889 goto herodraw_end;
2890 }
2891 3168 }
2892
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 8526887 times.
8527143 else if(action==lavadrowning)
2893 {
2894 256 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
2895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
256 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2896 256 }
2897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8526887 times.
8526887 else if(action==sidedrowning)
2898 {
2899 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
2900 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2901 }
2902
2/4
✓ Branch 0 taken 8526887 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8526887 times.
8526887 else if (action == sideswimming || action == sideswimhit)
2903 {
2904 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2905
2906 if(lstep>=6)
2907 {
2908 if(dir==up)
2909 {
2910 if(advancetile) ++flip;
2911 }
2912 else
2913 {
2914 if(advancetile) extend==2?tile+=2:++tile;
2915 }
2916 }
2917 }
2918
5/6
✓ Branch 0 taken 8432250 times.
✓ Branch 1 taken 94637 times.
✓ Branch 2 taken 8431429 times.
✓ Branch 3 taken 821 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8431429 times.
8526887 else if(action==swimming || action==swimhit || hopclk==0xFF)
2919 {
2920 95458 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
2921
2922
2/2
✓ Branch 0 taken 47669 times.
✓ Branch 1 taken 47789 times.
95458 if(lstep>=6)
2923 {
2924
2/2
✓ Branch 0 taken 38014 times.
✓ Branch 1 taken 9775 times.
47789 if(dir==up)
2925 {
2926
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9775 times.
9775 if(advancetile) ++flip;
2927 9775 }
2928 else
2929 {
2930
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38014 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38014 times.
38014 if(advancetile) extend==2?tile+=2:++tile;
2931 }
2932 47789 }
2933
2934
2/2
✓ Branch 0 taken 90255 times.
✓ Branch 1 taken 5203 times.
95458 if(isDiving())
2935 {
2936 5203 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
2937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5203 times.
5203 if(advancetile) tile+=((frame>>3) & 1)*(extend==2?2:1);
2938 5203 }
2939 95458 }
2940
3/4
✓ Branch 0 taken 1618 times.
✓ Branch 1 taken 8429811 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618 times.
8431429 else if(charging > 0 && attack != wHammer)
2941 {
2942 1618 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
2943
2944
2/2
✓ Branch 0 taken 943 times.
✓ Branch 1 taken 675 times.
1618 if(lstep>=6)
2945 {
2946
2/2
✓ Branch 0 taken 531 times.
✓ Branch 1 taken 144 times.
675 if(dir==up)
2947 {
2948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(advancetile) ++flip;
2949 144 }
2950 else
2951 {
2952
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 531 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 531 times.
531 if(advancetile) extend==2?tile+=2:++tile;
2953 }
2954 675 }
2955 1618 }
2956
7/10
✓ Branch 0 taken 8429569 times.
✓ Branch 1 taken 242 times.
✓ Branch 2 taken 8429569 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90047 times.
✓ Branch 5 taken 8339764 times.
✓ Branch 6 taken 90047 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 90047 times.
8429811 else if ((z > 0 || fakez > 0 || isSideViewHero()) && jumping_frame && game->get_life() > 0 && action != rafting)
2957 {
2958 90047 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
2959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90047 times.
90047 if (advancetile) tile += (*jumping_frame) * (extend == 2 ? 2 : 1);
2960 90047 }
2961
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 8337874 times.
8339764 else if(fallclk>0)
2962 {
2963 1890 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
2964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1890 times.
1890 if(advancetile) tile+=((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
2965 1890 }
2966
5/6
✓ Branch 0 taken 419450 times.
✓ Branch 1 taken 7918424 times.
✓ Branch 2 taken 585 times.
✓ Branch 3 taken 418865 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 585 times.
8337874 else if(!noliftspr&&action==lifting&&isLifting())
2967 {
2968 585 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
2969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(script_hero_sprite <= 0)
2970 {
2971 585 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
2972 585 auto speed = tliftclk/frames;
2973
1/2
✓ Branch 0 taken 585 times.
✗ Branch 1 not taken.
585 if (speed < 1) speed = 1;
2974 585 auto curframe = (tliftclk - liftclk) / speed;
2975
1/2
✓ Branch 0 taken 585 times.
✗ Branch 1 not taken.
585 if (!tliftclk) curframe = frames - 1;
2976
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
585 if(unsigned(curframe) < frames)
2977 585 tile += curframe * (extend == 2 ? 2 : 1);
2978 585 }
2979 585 }
2980 else
2981 {
2982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8337289 times.
8337289 if(IsSideSwim())
2983 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
2984 else
2985 {
2986
4/4
✓ Branch 0 taken 418865 times.
✓ Branch 1 taken 7918424 times.
✓ Branch 2 taken 410269 times.
✓ Branch 3 taken 8596 times.
8337289 if(!noliftspr&&isLifting())
2987 8596 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
2988 8328693 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
2989 }
2990
2991
2/2
✓ Branch 0 taken 2146869 times.
✓ Branch 1 taken 6190420 times.
8337289 if(dir>up)
2992 {
2993 6190420 useltm=true;
2994 6190420 }
2995
2996
3/4
✓ Branch 0 taken 8337289 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4060413 times.
✓ Branch 3 taken 4276876 times.
8337289 if(advancetile && lstep>=6)
2997 {
2998
2/2
✓ Branch 0 taken 3184241 times.
✓ Branch 1 taken 1092635 times.
4276876 if(dir==up)
2999 {
3000 1092635 ++flip;
3001 1092635 }
3002 else
3003 {
3004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3184241 times.
3184241 extend==2?tile+=2:++tile;
3005 }
3006 4276876 }
3007 }
3008
3009 8530311 break;
3010
3011 case las_bszelda: //BS
3012
2/2
✓ Branch 0 taken 2944 times.
✓ Branch 1 taken 6571559 times.
6574503 if(action==drowning)
3013 {
3014
1/2
✓ Branch 0 taken 2944 times.
✗ Branch 1 not taken.
2944 if(inwater)
3015 {
3016 2944 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
3017
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2944 times.
2944 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3018 2944 }
3019 else
3020 {
3021 goto herodraw_end;
3022 }
3023 2944 }
3024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6571559 times.
6571559 else if (action == sidedrowning)
3025 {
3026 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
3027 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3028 }
3029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6571559 times.
6571559 else if(action==lavadrowning)
3030 {
3031 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
3032 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3033 }
3034
2/4
✓ Branch 0 taken 6571559 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6571559 times.
6571559 else if (action == sideswimming || action == sideswimhit)
3035 {
3036 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
3037
3038 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3039 }
3040
6/6
✓ Branch 0 taken 6509915 times.
✓ Branch 1 taken 61644 times.
✓ Branch 2 taken 6509484 times.
✓ Branch 3 taken 431 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 6509327 times.
6571559 else if(action==swimming || action==swimhit || hopclk==0xFF)
3041 {
3042
2/2
✓ Branch 0 taken 15239 times.
✓ Branch 1 taken 46993 times.
62232 if (get_qr(qr_COPIED_SWIM_SPRITES))
3043 {
3044 15239 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
3045 15239 }
3046 else
3047 {
3048 46993 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
3049 }
3050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62232 times.
62232 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3051
3052
2/2
✓ Branch 0 taken 56358 times.
✓ Branch 1 taken 5874 times.
62232 if(isDiving())
3053 {
3054
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 5034 times.
5874 if (get_qr(qr_COPIED_SWIM_SPRITES))
3055 {
3056 840 herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
3057 840 }
3058 else
3059 {
3060 5034 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
3061 }
3062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5874 times.
5874 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3063 5874 }
3064 62232 }
3065
3/4
✓ Branch 0 taken 32285 times.
✓ Branch 1 taken 6477042 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32285 times.
6509327 else if(charging > 0 && attack != wHammer)
3066 {
3067 32285 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
3068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32285 times.
32285 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3069 32285 }
3070
6/8
✓ Branch 0 taken 6457531 times.
✓ Branch 1 taken 19511 times.
✓ Branch 2 taken 6457531 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12105 times.
✓ Branch 5 taken 6464937 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12105 times.
6477042 else if ((z > 0 || fakez > 0 || isSideViewHero()) && jumping_frame && game->get_life() > 0)
3071 {
3072 12105 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
3073
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 12036 times.
12105 if (advancetile) tile += (*jumping_frame) * (extend == 2 ? 2 : 1);
3074 12105 }
3075
2/2
✓ Branch 0 taken 1680 times.
✓ Branch 1 taken 6463257 times.
6464937 else if(fallclk>0)
3076 {
3077 1680 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
3078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
1680 if(advancetile) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
3079 1680 }
3080
5/6
✓ Branch 0 taken 410863 times.
✓ Branch 1 taken 6052394 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 410574 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 289 times.
6463257 else if(!noliftspr&&action==lifting&&isLifting())
3081 {
3082 289 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
3083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289 times.
289 if(script_hero_sprite <= 0)
3084 {
3085 289 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
3086 289 auto speed = tliftclk/frames;
3087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289 times.
289 if (speed < 1) speed = 1;
3088 289 auto curframe = (tliftclk - liftclk) / speed;
3089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289 times.
289 if (!tliftclk) curframe = frames - 1;
3090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289 times.
289 if(unsigned(curframe) < frames)
3091 289 tile += curframe * (extend == 2 ? 2 : 1);
3092 289 }
3093 289 }
3094 else
3095 {
3096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6462968 times.
6462968 if(IsSideSwim())
3097 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
3098 else
3099 {
3100
4/4
✓ Branch 0 taken 410574 times.
✓ Branch 1 taken 6052394 times.
✓ Branch 2 taken 408835 times.
✓ Branch 3 taken 1739 times.
6462968 if(!noliftspr&&isLifting())
3101 1739 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
3102 6461229 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
3103 }
3104
3105
2/2
✓ Branch 0 taken 1839670 times.
✓ Branch 1 taken 4623298 times.
6462968 if(dir > up)
3106 {
3107 4623298 useltm=true;
3108 4623298 }
3109
2/2
✓ Branch 0 taken 7693 times.
✓ Branch 1 taken 6455275 times.
6462968 if(advancetile) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3110 }
3111
3112 6574503 break;
3113
3114 case las_zelda3slow: //8-frame Zelda 3 (slow)
3115 case las_zelda3: //8-frame Zelda 3
3116 if(action == drowning)
3117 {
3118 if(inwater)
3119 {
3120 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_drown, dir, zinit.heroAnimationStyle);
3121 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3122 }
3123 else
3124 {
3125 goto herodraw_end;
3126 }
3127 }
3128 else if(action == lavadrowning)
3129 {
3130 herotile(&tile, &flip, &extend, (drownclk > 60) ? ls_float : ls_lavadrown, dir, zinit.heroAnimationStyle);
3131 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3132
3133 }
3134 else if(action == sidedrowning)
3135 {
3136 herotile(&tile, &flip, &extend, ls_sidedrown, down, zinit.heroAnimationStyle);
3137 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3138 }
3139 else if (action == sideswimming || action == sideswimhit)
3140 {
3141 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
3142
3143 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3144 }
3145 else if(action == swimming || action==swimhit || hopclk==0xFF)
3146 {
3147 herotile(&tile, &flip, &extend, is_moving()?ls_swim:ls_float, dir, zinit.heroAnimationStyle);
3148 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3149
3150 if(isDiving())
3151 {
3152 herotile(&tile, &flip, &extend, ls_dive, dir, zinit.heroAnimationStyle);
3153 if (script_hero_sprite <= 0 ) tile += anim_3_4(lstep,7)*(extend==2?2:1);
3154 }
3155 }
3156 else if(charging > 0 && attack != wHammer)
3157 {
3158 herotile(&tile, &flip, &extend, (IsSideSwim())?ls_sideswimcharge:ls_charge, dir, zinit.heroAnimationStyle);
3159 if (script_hero_sprite <= 0 ) tile+=(extend==2?2:1);
3160 //int32_t l=hero_count/hero_animation_speed;
3161 int32_t l=(hero_count/hero_animation_speed)&15;
3162 //int32_t l=((p[lt_clock]/hero_animation_speed)&15);
3163 l-=((l>3)?1:0)+((l>12)?1:0);
3164 if (script_hero_sprite <= 0 ) tile+=(l/2)*(extend==2?2:1);
3165 }
3166 else if ((z > 0 || fakez > 0 || isSideViewHero()) && jumping_frame && game->get_life() > 0)
3167 {
3168 herotile(&tile, &flip, &extend, ls_jump, dir, zinit.heroAnimationStyle);
3169 if (script_hero_sprite <= 0) tile += (*jumping_frame) * (extend == 2 ? 2 : 1);
3170 }
3171 else if(fallclk>0)
3172 {
3173 herotile(&tile, &flip, &extend, ls_falling, dir, zinit.heroAnimationStyle);
3174 if (script_hero_sprite <= 0 ) tile += ((PITFALL_FALL_FRAMES-fallclk)/10)*(extend==2?2:1);
3175 }
3176 else if(!noliftspr&&action==lifting&&isLifting())
3177 {
3178 herotile(&tile, &flip, &extend, ls_lifting, dir, zinit.heroAnimationStyle);
3179 if(script_hero_sprite <= 0)
3180 {
3181 auto frames = vbound(liftingspr[dir][spr_frames],1,255);
3182 auto speed = tliftclk/frames;
3183 if (speed < 1) speed = 1;
3184 auto curframe = (tliftclk-liftclk)/speed;
3185 if (!tliftclk) curframe = frames - 1;
3186 if(unsigned(curframe) < frames)
3187 tile += curframe * (extend == 2 ? 2 : 1);
3188 }
3189 }
3190 else
3191 {
3192 if(IsSideSwim())
3193 herotile(&tile, &flip, &extend, ls_sideswim, dir, zinit.heroAnimationStyle);
3194 else
3195 {
3196 if(!noliftspr&&isLifting())
3197 herotile(&tile, &flip, &extend, ls_liftwalk, dir, zinit.heroAnimationStyle);
3198 else herotile(&tile, &flip, &extend, ls_walk, dir, zinit.heroAnimationStyle);
3199 }
3200
3201 if(advancetile && (action == walking || action == climbcoverbottom || action == climbcovertop))
3202 {
3203 tile += (extend == 2 ? 2 : 1);
3204 }
3205
3206 if(dir>up)
3207 {
3208 useltm=true;
3209 }
3210
3211 if(advancetile && (action == walking || action == hopping || action == climbcoverbottom || action == climbcovertop))
3212 {
3213 //tile+=(extend==2?2:1);
3214 //tile+=(((active_count>>2)%8)*(extend==2?2:1));
3215 int32_t l = hero_count / hero_animation_speed;
3216 l -= ((l > 3) ? 1 : 0) + ((l > 12) ? 1 : 0);
3217 tile += (l / 2) * (extend == 2 ? 2 : 1);
3218 }
3219 }
3220
3221 break;
3222
3223 default:
3224 break;
3225 }
3226 15104814 }
3227
3228
6/6
✓ Branch 0 taken 6694723 times.
✓ Branch 1 taken 8412938 times.
✓ Branch 2 taken 4246862 times.
✓ Branch 3 taken 2447861 times.
✓ Branch 4 taken 170841 times.
✓ Branch 5 taken 4076021 times.
15107661 yofs = oyofs-((!BSZ && isdungeon() && cur_screen<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
3229
3230
2/2
✓ Branch 0 taken 15104357 times.
✓ Branch 1 taken 3304 times.
15107661 if(action==won)
3231 {
3232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3304 times.
3304 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - 2;
3233 3304 }
3234
3235
4/4
✓ Branch 0 taken 14949001 times.
✓ Branch 1 taken 158660 times.
✓ Branch 2 taken 93472 times.
✓ Branch 3 taken 14855529 times.
15107661 if(action==landhold1 || action==landhold2)
3236 {
3237 252132 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3238
6/6
✓ Branch 0 taken 106891 times.
✓ Branch 1 taken 145241 times.
✓ Branch 2 taken 80905 times.
✓ Branch 3 taken 25986 times.
✓ Branch 4 taken 14607 times.
✓ Branch 5 taken 66298 times.
252132 yofs = oyofs-((!BSZ && isdungeon() && cur_screen<128 && !get_qr(qr_HERODUNGEONPOSFIX)) ? 2 : 0);
3239 252132 herotile(&tile, &flip, &extend, (action==landhold1)?ls_landhold1:ls_landhold2, dir, zinit.heroAnimationStyle);
3240 252132 }
3241
4/4
✓ Branch 0 taken 14854174 times.
✓ Branch 1 taken 1355 times.
✓ Branch 2 taken 859 times.
✓ Branch 3 taken 14853315 times.
14855529 else if(action==waterhold1 || action==waterhold2)
3242 {
3243 2214 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3244 2214 herotile(&tile, &flip, &extend, (action==waterhold1)?ls_waterhold1:ls_waterhold2, dir, zinit.heroAnimationStyle);
3245 2214 }
3246
2/4
✓ Branch 0 taken 14853315 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14853315 times.
14853315 else if(action==sidewaterhold1 || action==sidewaterhold2)
3247 {
3248 useltm=(get_qr(qr_EXPANDEDLTM) != 0);
3249 herotile(&tile, &flip, &extend, (action==sidewaterhold1)?ls_sidewaterhold1:ls_sidewaterhold2, dir, zinit.heroAnimationStyle);
3250 }
3251
3252
3/4
✓ Branch 0 taken 15104814 times.
✓ Branch 1 taken 2847 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15104814 times.
15107661 if(action!=casting && action!=sideswimcasting)
3253 {
3254
2/2
✓ Branch 0 taken 2634525 times.
✓ Branch 1 taken 12470289 times.
15104814 if(useltm)
3255 {
3256
2/2
✓ Branch 0 taken 7762 times.
✓ Branch 1 taken 12462527 times.
12470289 if (script_hero_sprite <= 0 ) tile+=getTileModifier();
3257 12470289 }
3258 15104814 }
3259
3260 // Stone of Agony
3261
1/2
✓ Branch 0 taken 15107661 times.
✗ Branch 1 not taken.
15107661 if(agony)
3262 {
3263 yofs-=!(frame%zc_max(60-itemsbuf[agonyid].misc1,3))?1:0;
3264 }
3265
3266
2/2
✓ Branch 0 taken 63595 times.
✓ Branch 1 taken 15044066 times.
15107661 if(is_hitflickerframe())
3267 {
3268
4/6
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 63414 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 181 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 63414 times.
63595 int32_t temp_flicker_color = (game->get_life() > 0 || immortal) ? (flickercolor < 0 ? game->get_spriteflickercolor() : flickercolor) : 0;
3269
2/4
✓ Branch 0 taken 63595 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63595 times.
✗ Branch 3 not taken.
63595 if((game->get_spriteflickercolor() || temp_flicker_color) && !superman)
3270 {
3271 sprite_flicker_transp_passes = (flickertransp < 0 ? game->get_spriteflickertransp() : flickertransp);
3272 sprite_flicker_color = temp_flicker_color;
3273 masked_draw(dest);
3274 }
3275 63595 }
3276 else
3277 15044066 masked_draw(dest);
3278
3279 //draw held items after Hero so they don't go behind his head
3280
4/4
✓ Branch 0 taken 14949001 times.
✓ Branch 1 taken 158660 times.
✓ Branch 2 taken 93472 times.
✓ Branch 3 taken 14855529 times.
15107661 if(action==landhold1 || action==landhold2)
3281 {
3282
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 252110 times.
252132 if(holditem > -1)
3283 {
3284 252110 int hx = x - ((action==landhold1)?4:0);
3285 252110 int hy = y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z;
3286
2/2
✓ Branch 0 taken 140491 times.
✓ Branch 1 taken 111619 times.
252110 if(get_qr(qr_HOLDITEMANIMATION))
3287 {
3288 140491 putitem2(dest,hx,hy,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3289 140491 }
3290 else
3291 {
3292 111619 putitem(dest,hx,hy,holditem);
3293 }
3294 252110 }
3295 252132 }
3296
4/4
✓ Branch 0 taken 14854174 times.
✓ Branch 1 taken 1355 times.
✓ Branch 2 taken 859 times.
✓ Branch 3 taken 14853315 times.
14855529 else if(action==waterhold1 || action==waterhold2)
3297 {
3298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2214 times.
2214 if(holditem > -1)
3299 {
3300 2214 int hx = x - ((action==waterhold1)?4:0);
3301 2214 int hy = y+yofs-12-(get_qr(qr_NOITEMOFFSET))-fakez-z;
3302
2/2
✓ Branch 0 taken 1562 times.
✓ Branch 1 taken 652 times.
2214 if(get_qr(qr_HOLDITEMANIMATION))
3303 {
3304 1562 putitem2(dest,hx,hy,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3305 1562 }
3306 else
3307 {
3308 652 putitem(dest,hx,hy,holditem);
3309 }
3310 2214 }
3311 2214 }
3312
2/4
✓ Branch 0 taken 14853315 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14853315 times.
14853315 else if(action==sidewaterhold1 || action==sidewaterhold2) //!DIMITODO: Check to see if this looks right or if it needs waterhold's offset.
3313 {
3314 if(holditem > -1)
3315 {
3316 int hx = x - ((action==sidewaterhold1)?4:0);
3317 int hy = y+yofs-16-(get_qr(qr_NOITEMOFFSET))-fakez-z;
3318 if(get_qr(qr_HOLDITEMANIMATION))
3319 {
3320 putitem2(dest,hx,hy,holditem,lens_hint_item[holditem][0], lens_hint_item[holditem][1], 0);
3321 }
3322 else
3323 {
3324 putitem(dest,hx,hy,holditem);
3325 }
3326 }
3327 }
3328
4/4
✓ Branch 0 taken 23254 times.
✓ Branch 1 taken 15084407 times.
✓ Branch 2 taken 5125 times.
✓ Branch 3 taken 18129 times.
15107661 if(fairyclk==0||(get_qr(qr_NOHEARTRING)))
3329 {
3330 15089532 goto herodraw_end;
3331 }
3332
3333 18129 double a2 = fairyclk*4.5 + 90;
3334 18129 int32_t hearts=0;
3335 18129 int32_t htile = 2;
3336
3337 18129 do
3338 {
3339 110312 int32_t nx=125;
3340
3341
2/2
✓ Branch 0 taken 64232 times.
✓ Branch 1 taken 46080 times.
110312 if(get_qr(qr_HEARTRINGFIX))
3342 {
3343 46080 nx=x;
3344 46080 }
3345
3346 110312 int32_t ny=88;
3347
3348
2/2
✓ Branch 0 taken 64232 times.
✓ Branch 1 taken 46080 times.
110312 if(get_qr(qr_HEARTRINGFIX))
3349 {
3350 46080 ny=y;
3351 46080 }
3352
3353 110312 int32_t tx = zc::math::CosD(a2)*53 +nx;
3354 110312 int32_t ty = -zc::math::SinD(a2)*53 +ny+playing_field_offset;
3355 110312 overtile8(dest,htile,tx,ty,1,0);
3356 110312 a2-=45;
3357 110312 ++hearts;
3358
2/2
✓ Branch 0 taken 92183 times.
✓ Branch 1 taken 18129 times.
220624 }
3359
2/2
✓ Branch 0 taken 9920 times.
✓ Branch 1 taken 100392 times.
110312 while(a2>90 && hearts<8);
3360 18129 }
3361 herodraw_end:
3362 16873488 xofs=oxofs;
3363 16873488 yofs=oyofs;
3364 16873488 do_primitives(dest, SPLAYER_PLAYER_DRAW);
3365 16873488 }
3366
3367 16519307 void HeroClass::masked_draw(BITMAP* dest)
3368 {
3369 // The first sprite::draw in this function uses sprite_flicker_color
3370 // This is intended to be the player, handle this if this changes. -Moosh
3371 16519307 zfix lz, lfz;
3372
2/2
✓ Branch 0 taken 16508098 times.
✓ Branch 1 taken 11209 times.
16519307 if(lift_wpn)
3373 {
3374 11209 lz = lift_wpn->z;
3375 11209 lfz = lift_wpn->fakez;
3376 11209 }
3377
3378
12/12
✓ Branch 0 taken 6913027 times.
✓ Branch 1 taken 9606280 times.
✓ Branch 2 taken 6666809 times.
✓ Branch 3 taken 246218 times.
✓ Branch 4 taken 6515961 times.
✓ Branch 5 taken 150848 times.
✓ Branch 6 taken 6354501 times.
✓ Branch 7 taken 161460 times.
✓ Branch 8 taken 6161041 times.
✓ Branch 9 taken 193460 times.
✓ Branch 10 taken 6464852 times.
✓ Branch 11 taken 201957 times.
16519307 if(isdungeon() && cur_screen<128 && (x<16 || x>(world_w-32) || y<18 || y>(world_h-30)) && !get_qr(qr_FREEFORM))
3379 {
3380 // clip under doorways
3381 201957 BITMAP *sub=create_sub_bitmap(dest,16,playing_field_offset+16,224,144);
3382
3383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201957 times.
201957 if(sub!=NULL)
3384 {
3385 201957 yofs -= (playing_field_offset+16);
3386 201957 xofs -= 16;
3387 201957 sprite::draw(sub);
3388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201957 times.
201957 if(lift_wpn)
3389 {
3390 handle_lift(false);
3391 bool shad = lift_wpn->has_shadow;
3392 lift_wpn->has_shadow = false;
3393 lift_wpn->z += z;
3394 lift_wpn->fakez += fakez;
3395 lift_wpn->draw(sub);
3396 lift_wpn->has_shadow = shad;
3397 }
3398 201957 prompt_draw(sub);
3399 201957 xofs+=16;
3400 201957 yofs += (playing_field_offset+16);
3401 201957 destroy_bitmap(sub);
3402 201957 }
3403 201957 }
3404 else
3405 {
3406 16317350 sprite::draw(dest);
3407
2/2
✓ Branch 0 taken 16306141 times.
✓ Branch 1 taken 11209 times.
16317350 if(lift_wpn)
3408 {
3409 11209 handle_lift(false);
3410 11209 bool shad = lift_wpn->has_shadow;
3411 11209 lift_wpn->has_shadow = false;
3412 11209 lift_wpn->z += z;
3413 11209 lift_wpn->fakez += fakez;
3414 11209 lift_wpn->draw(dest);
3415 11209 lift_wpn->has_shadow = shad;
3416 11209 }
3417 16317350 prompt_draw(dest);
3418 }
3419
3420
2/2
✓ Branch 0 taken 16508098 times.
✓ Branch 1 taken 11209 times.
16519307 if(lift_wpn)
3421 {
3422 11209 lift_wpn->z = lz;
3423 11209 lift_wpn->fakez = lfz;
3424 11209 }
3425 16519307 return;
3426 }
3427 16519307 void HeroClass::prompt_draw(BITMAP* dest)
3428 {
3429
2/2
✓ Branch 0 taken 9958 times.
✓ Branch 1 taken 16509349 times.
16519307 if(!prompt_combo) return;
3430 9958 int32_t sx = real_x(x+xofs+prompt_x);
3431 9958 int32_t sy = real_y(y + yofs + prompt_y) - real_z(z + zofs);
3432 9958 sy -= fake_z(fakez);
3433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9958 times.
9958 if(combobuf[prompt_combo].animflags & AF_EDITOR_ONLY) return;
3434 9958 overcombo(dest, sx - viewport.x, sy - viewport.y, prompt_combo, prompt_cset);
3435 9958 return;
3436 16519307 }
3437
3438 21384 void collectitem_script(int32_t id)
3439 {
3440
2/2
✓ Branch 0 taken 21077 times.
✓ Branch 1 taken 307 times.
21384 if(itemsbuf[id].collect_script)
3441 {
3442 //clear item script stack.
3443 307 FFCore.clear_ref(ScriptType::Item, -id);
3444
3445
2/6
✓ Branch 0 taken 307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 307 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
307 if ( id > 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ) //No collect script on item 0.
3446 {
3447 307 int i = -id;
3448 307 FFCore.reset_script_engine_data(ScriptType::Item, i);
3449 307 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3450 307 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
3451 307 }
3452 else if (id == 0 && !(FFCore.doscript(ScriptType::Item, -id) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING))) //item 0
3453 {
3454 int i = COLLECT_SCRIPT_ITEM_ZERO;
3455 FFCore.reset_script_engine_data(ScriptType::Item, i);
3456 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].collect_script, i);
3457 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
3458 }
3459 //runningItemScripts[id] = 0;
3460 307 }
3461 21384 }
3462 4129 void passiveitem_script(int32_t id, bool doRun = false)
3463 {
3464 //Passive item scripts on colelction
3465
3/6
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 4073 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4129 if(itemsbuf[id].script && ( (itemsbuf[id].flags&item_passive_script) && (get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) ))
3466 {
3467 FFCore.reset_script_engine_data(ScriptType::Item, id);
3468
3469 if(get_qr(qr_PASSIVE_ITEM_SCRIPT_ONLY_HIGHEST)
3470 && current_item(itemsbuf[id].type) > itemsbuf[id].level)
3471 {
3472 FFCore.doscript(ScriptType::Item, id) = false;
3473 return;
3474 }
3475 if(doRun)
3476 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id].script, id);
3477 }
3478 4129 }
3479
3480 // separate case for sword/wand/hammer/slashed weapons only
3481 // the main weapon checking is in the global function check_collisions()
3482 14307772 bool HeroClass::checkstab()
3483 {
3484
14/14
✓ Branch 0 taken 12679949 times.
✓ Branch 1 taken 1627823 times.
✓ Branch 2 taken 365015 times.
✓ Branch 3 taken 1262808 times.
✓ Branch 4 taken 339546 times.
✓ Branch 5 taken 25469 times.
✓ Branch 6 taken 275127 times.
✓ Branch 7 taken 64419 times.
✓ Branch 8 taken 275099 times.
✓ Branch 9 taken 28 times.
✓ Branch 10 taken 253729 times.
✓ Branch 11 taken 21370 times.
✓ Branch 12 taken 376366 times.
✓ Branch 13 taken 997728 times.
14307772 if(action!=attacking && action!=sideswimattacking || (attack!=wSword && attack!=wWand && attack!=wHammer && attack!=wCByrna && attack!=wFire && attack != wBugNet)
3485 1627823 || (attackclk<=4))
3486 13310044 return false;
3487
3488 997728 weapon *w=NULL;
3489
3490 997728 int32_t wx=0,wy=0,wz=0,wxsz=0,wysz=0;
3491 997728 bool found = false;
3492 997728 int32_t melee_weapon_index = 0;
3493 997728 int32_t parentitem=-1;
3494 997728 weapon* meleeweap = nullptr;
3495
2/2
✓ Branch 0 taken 60656 times.
✓ Branch 1 taken 1108417 times.
1169073 for(int32_t i=0; i<Lwpns.Count(); i++)
3496 {
3497 1108417 w = (weapon*)Lwpns.spr(i);
3498
3499
6/6
✓ Branch 0 taken 1108379 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 19045 times.
✓ Branch 3 taken 1089334 times.
✓ Branch 4 taken 171345 times.
✓ Branch 5 taken 937072 times.
1108417 if(w->id == (attack==wCByrna || attack==wFire ? wWand : attack)) // Kludge: Byrna and Candle sticks are wWand-type.
3500 {
3501 937072 found = true;
3502 937072 melee_weapon_index = i+1;
3503 937072 meleeweap = w;
3504 // Position the sword as Hero slashes with it.
3505
4/4
✓ Branch 0 taken 881644 times.
✓ Branch 1 taken 55428 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 881530 times.
937072 if(w->id!=wHammer&&w->id!=wBugNet)
3506 881530 positionSword(w,w->parentitem);
3507
3508 937072 wx=w->x;
3509 937072 wy=w->y;
3510 937072 wz=w->z;
3511 937072 wxsz = w->hit_width;
3512 937072 wysz = w->hit_height;
3513 937072 parentitem = w->parentitem;
3514 937072 break;
3515 }
3516 171345 }
3517
3518
6/6
✓ Branch 0 taken 909327 times.
✓ Branch 1 taken 88401 times.
✓ Branch 2 taken 135406 times.
✓ Branch 3 taken 773921 times.
✓ Branch 4 taken 39264 times.
✓ Branch 5 taken 96142 times.
997728 if(attack==wSword && attackclk>=14 && charging==0)
3519 96142 return false;
3520
3521
2/2
✓ Branch 0 taken 840930 times.
✓ Branch 1 taken 60656 times.
901586 if(!found)
3522 60656 return false;
3523
3524
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 840507 times.
840930 if(attack == wFire)
3525 423 return false;
3526
3527
2/2
✓ Branch 0 taken 785079 times.
✓ Branch 1 taken 55428 times.
840507 if(attack==wHammer)
3528 {
3529
2/2
✓ Branch 0 taken 21966 times.
✓ Branch 1 taken 33462 times.
55428 if(attackclk<15)
3530 {
3531
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3427 times.
✓ Branch 2 taken 5263 times.
✓ Branch 3 taken 7217 times.
✓ Branch 4 taken 6059 times.
21966 switch(w->dir)
3532 {
3533 case up:
3534 3427 wx=x-1;
3535 3427 wy=y-4;
3536 3427 break;
3537
3538 case down:
3539 5263 wx=x+8;
3540 5263 wy=y+28;
3541 5263 break; // This is consistent with 2.10
3542
3543 case left:
3544 7217 wx=x-13;
3545 7217 wy=y+14;
3546 7217 break;
3547
3548 case right:
3549 6059 wx=x+21;
3550 6059 wy=y+14;
3551 6059 break;
3552 }
3553
3554
6/8
✓ Branch 0 taken 2172 times.
✓ Branch 1 taken 19794 times.
✓ Branch 2 taken 2172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2172 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2167 times.
21966 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
3555 {
3556 //decorations.add(new dHammerSmack((zfix)wx, (zfix)wy, dHAMMERSMACK, 0));
3557 /* The hammer smack sprites weren't being positioned properly if Hero changed directions on the same frame that they are created.
3558 switch(dir)
3559 {
3560 case up:
3561 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
3562 break;
3563
3564 case down:
3565 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
3566 break;
3567
3568 case left:
3569 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
3570 break;
3571
3572 case right:
3573 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
3574 break;
3575 }
3576 */
3577 2167 }
3578
3579 21966 return false;
3580 }
3581
2/2
✓ Branch 0 taken 31330 times.
✓ Branch 1 taken 2132 times.
33462 else if(attackclk==15)
3582 {
3583 // Hammer's reach needs adjusted slightly for backward compatibility
3584
2/2
✓ Branch 0 taken 1795 times.
✓ Branch 1 taken 337 times.
2132 if(w->dir==up)
3585 337 w->hyofs-=1;
3586
2/2
✓ Branch 0 taken 1097 times.
✓ Branch 1 taken 698 times.
1795 else if(w->dir==left)
3587 698 w->hxofs-=2;
3588 2132 }
3589 33462 }
3590
3591 // The return of Spaghetti Code Constants!
3592
6/6
✓ Branch 0 taken 16297 times.
✓ Branch 1 taken 802244 times.
✓ Branch 2 taken 768650 times.
✓ Branch 3 taken 33594 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 33576 times.
818541 int32_t itype = (attack==wWand ? itype_wand : attack==wSword ? itype_sword : attack==wCByrna ? itype_cbyrna : attack==wBugNet ? itype_bugnet : itype_hammer);
3593
4/4
✓ Branch 0 taken 84445 times.
✓ Branch 1 taken 734096 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 84417 times.
818541 int32_t itemid = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
3594 818541 itemid = vbound(itemid, 0, MAXITEMS-1);
3595
3596 // The sword offsets aren't based on anything other than what felt about right
3597 // compared to the NES game and what mostly kept it from hitting things that
3598 // should clearly be out of range. They could probably still use more tweaking.
3599 // Don't use 2.10 for reference; it's pretty far off.
3600 // - Saf
3601
3602
6/6
✓ Branch 0 taken 436104 times.
✓ Branch 1 taken 382437 times.
✓ Branch 2 taken 24782 times.
✓ Branch 3 taken 411322 times.
✓ Branch 4 taken 408480 times.
✓ Branch 5 taken 27624 times.
818541 if(game->get_canslash() && (attack==wSword || attack==wWand) && itemsbuf[itemid].flags & item_flag4)
3603 {
3604
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 71025 times.
✓ Branch 2 taken 89454 times.
✓ Branch 3 taken 125856 times.
✓ Branch 4 taken 122145 times.
408480 switch(w->dir)
3605 {
3606 case up:
3607
2/2
✓ Branch 0 taken 48514 times.
✓ Branch 1 taken 22511 times.
71025 if(attackclk<8)
3608 {
3609 22511 wy-=4;
3610 22511 }
3611
3612 71025 break;
3613
3614 case down:
3615 //if(attackclk<8)
3616 {
3617 89454 wy-=2;
3618 }
3619 89454 break;
3620
3621 case left:
3622
3623 //if(attackclk<8)
3624 {
3625 125856 wx+=2;
3626 }
3627
3628 125856 break;
3629
3630 case right:
3631
3632 //if(attackclk<8)
3633 {
3634 122145 wx-=3;
3635 //wy+=((spins>0 || get_qr(qr_SLASHFLIPFIX)) ? -4 : 4);
3636 }
3637
3638 122145 break;
3639 }
3640 408480 }
3641
3642
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 165605 times.
✓ Branch 2 taken 176608 times.
✓ Branch 3 taken 237908 times.
✓ Branch 4 taken 238420 times.
818541 switch(w->dir)
3643 {
3644 case up:
3645 165605 wx+=2;
3646 165605 break;
3647
3648 case down:
3649 176608 break;
3650
3651 case left:
3652 237908 wy-=3;
3653 237908 break;
3654
3655 case right:
3656 238420 wy-=3;
3657 238420 break;
3658 }
3659
3660 818541 wx+=w->hxofs;
3661 818541 wy+=w->hyofs;
3662 818541 wy-=(w->fakez).getInt();
3663
3664
2/2
✓ Branch 0 taken 812112 times.
✓ Branch 1 taken 3502887 times.
4314999 for(int32_t i=0; i<guys.Count(); i++)
3665 {
3666
2/2
✓ Branch 0 taken 3502792 times.
✓ Branch 1 taken 95 times.
3502887 if(attack==wBugNet) break;
3667 // So that Hero can actually hit peahats while jumping, his weapons' hzsz becomes 16 in midair.
3668
6/6
✓ Branch 0 taken 74476 times.
✓ Branch 1 taken 3428316 times.
✓ Branch 2 taken 73881 times.
✓ Branch 3 taken 595 times.
✓ Branch 4 taken 72186 times.
✓ Branch 5 taken 1695 times.
3503348 if((guys.spr(i)->hit(wx,wy,wz,wxsz,wysz,wz>0?16:8) && ((attack!=wWand && attack!=wHammer && attack!=wCByrna) || !(itemsbuf[itemid].flags & item_flag3)))
3669
5/6
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2524 times.
✓ Branch 2 taken 3325176 times.
✓ Branch 3 taken 103848 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3429024 times.
3430606 || ((attack==wWand || attack==wCByrna) && guys.spr(i)->hit(wx,wy-8,z,16,24,z>8) && !(itemsbuf[itemid].flags & item_flag3))
3670
4/4
✓ Branch 0 taken 120275 times.
✓ Branch 1 taken 3308749 times.
✓ Branch 2 taken 556 times.
✓ Branch 3 taken 119719 times.
3429024 || (attack==wHammer && guys.spr(i)->hit(wx,wy-8,z,16,24,z>0?16:8) && !(itemsbuf[itemid].flags & item_flag3)))
3671 {
3672 // Checking the whimsical ring for every collision check causes
3673 // an odd bug. It's much more likely to activate on a 0-damage
3674 // weapon, since a 0-damage hit won't make the enemy invulnerable
3675 // to damaging hits in the following frames.
3676
3677 74710 int32_t whimsyid = current_item_id(itype_whimsicalring);
3678
3679 74710 int32_t dmg = weaponattackpower(itemid);
3680
2/2
✓ Branch 0 taken 72801 times.
✓ Branch 1 taken 1909 times.
74710 if(whimsyid>-1)
3681 {
3682
3/4
✓ Branch 0 taken 1909 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1793 times.
✓ Branch 3 taken 116 times.
1909 if(!(zc_oldrand()%zc_max(itemsbuf[whimsyid].misc1,1)))
3683 116 dmg += current_item_power(itype_whimsicalring);
3684 1793 else whimsyid = -1;
3685 1909 }
3686 74710 int32_t atkringid = current_item_id(itype_atkring);
3687
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 74702 times.
74710 if(atkringid>-1)
3688 {
3689 8 dmg *= itemsbuf[atkringid].misc2; //Multiplier
3690 8 dmg += itemsbuf[atkringid].misc1; //Additive
3691 8 }
3692
3693 74710 int32_t h = hit_enemy(i,attack,dmg*game->get_hero_dmgmult(),wx,wy,dir,directWpn,w);
3694 74710 enemy *e = (enemy*)guys.spr(i);
3695
2/2
✓ Branch 0 taken 19817 times.
✓ Branch 1 taken 54893 times.
74710 if (h < 0)
3696 {
3697 54893 e->hitby[HIT_BY_LWEAPON] = melee_weapon_index;
3698 54893 e->hitby[HIT_BY_LWEAPON_UID] = w->getUID();
3699 54893 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
3700
1/2
✓ Branch 0 taken 54893 times.
✗ Branch 1 not taken.
54893 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].type;
3701 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
3702 54893 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
3703 54893 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
3704 54893 } //temp_hit = true; }
3705 //melee weapons and non-melee weapons both writing to this index may be a problem. It needs to be cleared by something earlier than this check.
3706
3707
4/4
✓ Branch 0 taken 54893 times.
✓ Branch 1 taken 19817 times.
✓ Branch 2 taken 75 times.
✓ Branch 3 taken 54818 times.
74710 if(h<0 && whimsyid>-1)
3708 {
3709 75 sfx(itemsbuf[whimsyid].usesound);
3710 75 }
3711
3712
4/4
✓ Branch 0 taken 63441 times.
✓ Branch 1 taken 11269 times.
✓ Branch 2 taken 62961 times.
✓ Branch 3 taken 480 times.
74710 if(h && charging>0)
3713 {
3714 480 attackclk = SWORDTAPFRAME;
3715 480 spins=0;
3716 480 }
3717
3718
8/8
✓ Branch 0 taken 63441 times.
✓ Branch 1 taken 11269 times.
✓ Branch 2 taken 53759 times.
✓ Branch 3 taken 9682 times.
✓ Branch 4 taken 53725 times.
✓ Branch 5 taken 34 times.
✓ Branch 6 taken 1217 times.
✓ Branch 7 taken 52508 times.
74710 if(h && hclk==0 && inlikelike != 1 && !get_qr(qr_DYING_ENEMIES_IGNORE_STUN))
3719 {
3720
2/2
✓ Branch 0 taken 52351 times.
✓ Branch 1 taken 157 times.
52508 if(GuyHit(i,x+7,y+7-fakez,z,2,2,hzsz)!=-1)
3721 {
3722 157 hithero(i);
3723 157 }
3724 52508 }
3725
3726
2/2
✓ Branch 0 taken 67434 times.
✓ Branch 1 taken 7276 times.
74710 if(abs(h)==2)
3727 7276 break;
3728 67434 }
3729 3496458 }
3730
3731
2/2
✓ Branch 0 taken 18938 times.
✓ Branch 1 taken 799489 times.
1637910 if(attack == wBugNet
3732
3/4
✓ Branch 0 taken 818427 times.
✓ Branch 1 taken 1056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 818427 times.
819483 || (parentitem==-1&&!get_qr(qr_NOITEMMELEE))
3733
1/2
✓ Branch 0 taken 818427 times.
✗ Branch 1 not taken.
818427 || (parentitem>-1&&!(itemsbuf[parentitem].flags & item_flag7)))
3734 {
3735
3/4
✓ Branch 0 taken 800431 times.
✓ Branch 1 taken 114 times.
✓ Branch 2 taken 114 times.
✗ Branch 3 not taken.
800545 int32_t bugnetid = attack != wBugNet ? -1 : (parentitem > -1 ? parentitem : current_item_id(itype_bugnet));
3736
2/2
✓ Branch 0 taken 800545 times.
✓ Branch 1 taken 256564 times.
1057109 for(int32_t j=0; j<items.Count(); j++)
3737 {
3738 256564 item* ptr = (item*)items.spr(j);
3739
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 256544 times.
256565 bool dofairy = (attack==wBugNet && itemsbuf[ptr->id].type == itype_fairy)
3740
3/4
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
20 && (bugnetid > -1 && !(itemsbuf[bugnetid].flags & item_flag1));
3741
3742
2/4
✓ Branch 0 taken 256564 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256564 times.
✗ Branch 3 not taken.
256564 if((itemsbuf[ptr->id].type == itype_bottlefill || dofairy) && !game->canFillBottle())
3743 continue; //No picking these up unless you have a bottle to fill!
3744
5/6
✓ Branch 0 taken 256537 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 48597 times.
✓ Branch 3 taken 207940 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 48597 times.
256564 if((ptr->pickup & ipCANGRAB) || (ptr->pickup & ipTIMER) || dofairy)
3745 {
3746
7/8
✓ Branch 0 taken 207940 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 97068 times.
✓ Branch 3 taken 110872 times.
✓ Branch 4 taken 110899 times.
✓ Branch 5 taken 97068 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 110899 times.
207967 if(((ptr->pickup & ipCANGRAB) || ptr->clk2 >= 32 || dofairy) && !ptr->fallclk && !ptr->drownclk)
3747 {
3748
6/6
✓ Branch 0 taken 103964 times.
✓ Branch 1 taken 6935 times.
✓ Branch 2 taken 981 times.
✓ Branch 3 taken 102983 times.
✓ Branch 4 taken 103949 times.
✓ Branch 5 taken 6950 times.
214860 if(ptr->hit(wx,wy,z,wxsz,wysz,1) || (attack==wWand && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1))
3749
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 978 times.
✓ Branch 2 taken 101210 times.
✓ Branch 3 taken 2751 times.
103964 || (attack==wHammer && ptr->hit(x,y-8-fakez,z,wxsz,wysz,1)))
3750 {
3751 6950 int screen = get_screen_for_world_xy(wx, wy);
3752 6950 mapscr* scr = get_scr_for_world_xy(wx, wy);
3753 6950 int32_t pickup = ptr->pickup;
3754 6950 int32_t id2 = ptr->id;
3755 6950 int32_t pstr = ptr->pstring;
3756 6950 int32_t pstr_flags = ptr->pickup_string_flags;
3757 6950 int32_t pstr_screen = ptr->screen_spawned;
3758
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6949 times.
6950 if(!dofairy)
3759 {
3760 6949 std::vector<int32_t> &ev = FFCore.eventData;
3761 6949 ev.clear();
3762 6949 ev.push_back(id2*10000);
3763 6949 ev.push_back(pickup*10000);
3764 6949 ev.push_back(pstr*10000);
3765 6949 ev.push_back(pstr_flags*10000);
3766 6949 ev.push_back(0);
3767 6949 ev.push_back(ptr->getUID());
3768 6949 ev.push_back(GENEVT_ICTYPE_MELEE*10000);
3769 6949 ev.push_back(w->getUID());
3770
3771 6949 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
3772 6949 bool nullify = ev[4] != 0;
3773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6949 times.
6949 if(nullify) continue;
3774 6949 id2 = ev[0]/10000;
3775 6949 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
3776 6949 pstr = ev[2] / 10000;
3777 6949 pstr_flags = ev[3] / 10000;
3778 6949 }
3779
3780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6950 times.
6950 if(pickup&ipONETIME) // set mITEM for one-time-only items
3781 setmapflag(scr, mITEM);
3782
1/2
✓ Branch 0 taken 6950 times.
✗ Branch 1 not taken.
6950 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
3783 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
3784
3785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6950 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6950 if(ptr->pickupexstate > -1 && ptr->pickupexstate < 32)
3786 setxmapflag(screen, 1<<ptr->pickupexstate);
3787
1/2
✓ Branch 0 taken 6950 times.
✗ Branch 1 not taken.
6950 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
3788 {
3789 if (scr->flags9&fITEMSECRETPERM) setmapflag(scr, mSECRET);
3790 trigger_secrets_for_screen(TriggerSource::ItemsSecret, scr, false);
3791 }
3792 //!DIMI
3793
3794
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 6949 times.
6950 if(dofairy)
3795 {
3796 1 game->fillBottle(itemsbuf[ptr->id].misc4);
3797 1 }
3798 else
3799 {
3800 6949 collectitem_script(id2);
3801
3802 6949 getitem(id2, ptr->noSound, true);
3803 }
3804 6950 items.del(j);
3805
3806
2/2
✓ Branch 0 taken 8006 times.
✓ Branch 1 taken 6950 times.
14956 for(int32_t i=0; i<Lwpns.Count(); i++)
3807 {
3808 8006 weapon *w2 = (weapon*)Lwpns.spr(i);
3809
3810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8006 times.
8006 if(w2->dragging==j)
3811 {
3812 w2->dragging=-1;
3813 }
3814
1/2
✓ Branch 0 taken 8006 times.
✗ Branch 1 not taken.
8006 else if(w2->dragging>j)
3815 {
3816 w2->dragging-=1;
3817 }
3818 8006 }
3819
3820
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6950 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6950 if ( (pstr > 0 && pstr < msg_count) )
3821 {
3822 if ( ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
3823 {
3824 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) )
3825 FFCore.SetItemMessagePlayed(id2);
3826 donewmsg(get_scr(pstr_screen), pstr);
3827 break;
3828 }
3829 }
3830
3831 6950 --j;
3832 6950 }
3833 110899 }
3834 207967 }
3835 256564 }
3836 800545 }
3837
3838
4/4
✓ Branch 0 taken 818523 times.
✓ Branch 1 taken 960 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 818409 times.
819483 if(attack==wCByrna || attack==wBugNet)
3839 1074 return false;
3840
3841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 818409 times.
818409 if(meleeweap->no_triggers())
3842 return false;
3843
3844
2/2
✓ Branch 0 taken 768650 times.
✓ Branch 1 taken 49759 times.
818409 if(attack==wSword)
3845 {
3846
2/2
✓ Branch 0 taken 681986 times.
✓ Branch 1 taken 86664 times.
768650 if(attackclk == 6)
3847 {
3848
2/2
✓ Branch 0 taken 15252864 times.
✓ Branch 1 taken 86664 times.
15339528 for(int32_t q=0; q<176; q++)
3849 {
3850 15252864 set_bit(screengrid,q,0);
3851 15252864 set_bit(screengrid_layer[0],q,0);
3852 15252864 set_bit(screengrid_layer[1],q,0);
3853 15252864 }
3854
3855 2731808 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
3856 2645144 ffc_handle.ffc->recently_hit = false;
3857 2645144 });
3858 86664 }
3859
3860
4/4
✓ Branch 0 taken 157230 times.
✓ Branch 1 taken 611420 times.
✓ Branch 2 taken 72549 times.
✓ Branch 3 taken 84681 times.
768650 if(dir==up && ((x.getInt()&15)==0))
3861 {
3862 72549 check_slash_block(wx,wy);
3863 72549 check_slash_block(wx,wy+8);
3864
3865 //layers
3866 72549 check_slash_block_layer(wx,wy,1);
3867 72549 check_slash_block_layer(wx,wy+8,1);
3868 72549 check_slash_block_layer(wx,wy,1);
3869 72549 check_slash_block_layer(wx,wy+8,1);
3870 //2
3871 72549 check_slash_block_layer(wx,wy,2);
3872 72549 check_slash_block_layer(wx,wy+8,2);
3873 72549 check_slash_block_layer(wx,wy,2);
3874 72549 check_slash_block_layer(wx,wy+8,2);
3875 72549 }
3876
8/10
✓ Branch 0 taken 84681 times.
✓ Branch 1 taken 611420 times.
✓ Branch 2 taken 26457 times.
✓ Branch 3 taken 58224 times.
✓ Branch 4 taken 240 times.
✓ Branch 5 taken 26217 times.
✓ Branch 6 taken 240 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 240 times.
696101 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3877 {
3878 84441 check_slash_block(wx,wy);
3879 84441 check_slash_block(wx,wy+8);
3880 84441 check_slash_block(wx+8,wy);
3881 84441 check_slash_block(wx+8,wy+8);
3882 ///layer 1
3883 84441 check_slash_block_layer(wx,wy,1);
3884 84441 check_slash_block_layer(wx,wy+8,1);
3885 84441 check_slash_block_layer(wx+8,wy,1);
3886 84441 check_slash_block_layer(wx+8,wy+8,1);
3887 ///layer 2
3888 84441 check_slash_block_layer(wx,wy,2);
3889 84441 check_slash_block_layer(wx,wy+8,2);
3890 84441 check_slash_block_layer(wx+8,wy,2);
3891 84441 check_slash_block_layer(wx+8,wy+8,2);
3892 84441 }
3893
4/4
✓ Branch 0 taken 166158 times.
✓ Branch 1 taken 602492 times.
✓ Branch 2 taken 87048 times.
✓ Branch 3 taken 79110 times.
768650 if(dir==down && ((x.getInt()&15)==0))
3894 {
3895 79110 check_slash_block(wx,wy+wysz-8);
3896 79110 check_slash_block(wx,wy+wysz);
3897
3898 //layer 1
3899 79110 check_slash_block_layer(wx,wy+wysz-8,1);
3900 79110 check_slash_block_layer(wx,wy+wysz,1);
3901 //layer 2
3902 79110 check_slash_block_layer(wx,wy+wysz-8,2);
3903 79110 check_slash_block_layer(wx,wy+wysz,2);
3904 79110 }
3905
8/10
✓ Branch 0 taken 87048 times.
✓ Branch 1 taken 602492 times.
✓ Branch 2 taken 35482 times.
✓ Branch 3 taken 51566 times.
✓ Branch 4 taken 333 times.
✓ Branch 5 taken 35149 times.
✓ Branch 6 taken 333 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 333 times.
689540 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3906 {
3907 86715 check_slash_block(wx,wy+wysz-8);
3908 86715 check_slash_block(wx,wy+wysz);
3909 86715 check_slash_block(wx+8,wy+wysz-8);
3910 86715 check_slash_block(wx+8,wy+wysz);
3911 //layer 1
3912 86715 check_slash_block_layer(wx,wy+wysz-8,1);
3913 86715 check_slash_block_layer(wx,wy+wysz,1);
3914 86715 check_slash_block_layer(wx+8,wy+wysz-8,1);
3915 86715 check_slash_block_layer(wx+8,wy+wysz,1);
3916 //layer 2
3917 86715 check_slash_block_layer(wx,wy+wysz-8,2);
3918 86715 check_slash_block_layer(wx,wy+wysz,2);
3919 86715 check_slash_block_layer(wx+8,wy+wysz-8,2);
3920 86715 check_slash_block_layer(wx+8,wy+wysz,2);
3921 86715 }
3922
3923
2/2
✓ Branch 0 taken 547830 times.
✓ Branch 1 taken 220820 times.
768650 if(dir==left)
3924 {
3925 220820 check_slash_block(wx,wy+8);
3926 220820 check_slash_block(wx+8,wy+8);
3927 //layer 1
3928 220820 check_slash_block_layer(wx,wy+8,1);
3929 220820 check_slash_block_layer(wx+8,wy+8,1);
3930 //layer 2
3931 220820 check_slash_block_layer(wx,wy+8,2);
3932 220820 check_slash_block_layer(wx+8,wy+8,2);
3933 220820 }
3934
3935
2/2
✓ Branch 0 taken 544208 times.
✓ Branch 1 taken 224442 times.
768650 if(dir==right)
3936 {
3937 224442 check_slash_block(wx+wxsz,wy+8);
3938 224442 check_slash_block(wx+wxsz-8,wy+8);
3939 //layer 1
3940 224442 check_slash_block_layer(wx+wxsz,wy+8,1);
3941 224442 check_slash_block_layer(wx+wxsz-8,wy+8,1);
3942 //layer 2
3943 224442 check_slash_block_layer(wx+wxsz,wy+8,2);
3944 224442 check_slash_block_layer(wx+wxsz-8,wy+8,2);
3945 224442 }
3946 768650 }
3947
2/2
✓ Branch 0 taken 16297 times.
✓ Branch 1 taken 33462 times.
49759 else if(attack==wWand)
3948 {
3949
1/2
✓ Branch 0 taken 16297 times.
✗ Branch 1 not taken.
16297 if(attackclk == 5)
3950 {
3951 for(int32_t q=0; q<176; q++)
3952 {
3953 set_bit(screengrid,q,0);
3954 set_bit(screengrid_layer[0],q,0);
3955 set_bit(screengrid_layer[1],q,0);
3956 }
3957
3958 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
3959 ffc_handle.ffc->recently_hit = false;
3960 });
3961 }
3962
3963 // cutable blocks
3964
4/4
✓ Branch 0 taken 3074 times.
✓ Branch 1 taken 13223 times.
✓ Branch 2 taken 1386 times.
✓ Branch 3 taken 1688 times.
16297 if(dir==up && (x.getInt()&15)==0)
3965 {
3966 1386 check_wand_block(wx,wy);
3967 1386 check_wand_block(wx,wy+8);
3968 1386 }
3969
5/10
✓ Branch 0 taken 1688 times.
✓ Branch 1 taken 13223 times.
✓ Branch 2 taken 813 times.
✓ Branch 3 taken 875 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 813 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
14911 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3970 {
3971 1688 check_wand_block(wx,wy);
3972 1688 check_wand_block(wx,wy+8);
3973 1688 check_wand_block(wx+8,wy);
3974 1688 check_wand_block(wx+8,wy+8);
3975 1688 }
3976
3977
4/4
✓ Branch 0 taken 2366 times.
✓ Branch 1 taken 13931 times.
✓ Branch 2 taken 1135 times.
✓ Branch 3 taken 1231 times.
16297 if(dir==down && (x.getInt()&15)==0)
3978 {
3979 1231 check_wand_block(wx,wy+wysz-8);
3980 1231 check_wand_block(wx,wy+wysz);
3981 1231 }
3982
5/10
✓ Branch 0 taken 1135 times.
✓ Branch 1 taken 13931 times.
✓ Branch 2 taken 307 times.
✓ Branch 3 taken 828 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 307 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
15066 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
3983 {
3984 1135 check_wand_block(wx,wy+wysz-8);
3985 1135 check_wand_block(wx,wy+wysz);
3986 1135 check_wand_block(wx+8,wy+wysz-8);
3987 1135 check_wand_block(wx+8,wy+wysz);
3988 1135 }
3989
3990
2/2
✓ Branch 0 taken 10184 times.
✓ Branch 1 taken 6113 times.
16297 if(dir==left)
3991 {
3992 6113 check_wand_block(wx,y+8);
3993 6113 check_wand_block(wx+8,y+8);
3994 6113 }
3995
3996
2/2
✓ Branch 0 taken 11553 times.
✓ Branch 1 taken 4744 times.
16297 if(dir==right)
3997 {
3998 4744 check_wand_block(wx+wxsz,y+8);
3999 4744 check_wand_block(wx+wxsz-8,y+8);
4000 4744 }
4001 16297 }
4002
4/8
✓ Branch 0 taken 33462 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31330 times.
✓ Branch 3 taken 2132 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 31330 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
33462 else if((attack==wHammer) && ((attackclk==15) || ( spins>0 && attackclk >=15 )))
4003 {
4004 // poundable blocks
4005
2/2
✓ Branch 0 taken 375232 times.
✓ Branch 1 taken 2132 times.
377364 for(int32_t q=0; q<176; q++)
4006 {
4007 375232 set_bit(screengrid,q,0);
4008 375232 set_bit(screengrid_layer[0],q,0);
4009 375232 set_bit(screengrid_layer[1],q,0);
4010 375232 }
4011
4012 69740 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
4013 67608 ffc_handle.ffc->recently_hit = false;
4014 67608 });
4015
4016
4/4
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 1794 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 164 times.
2132 if(dir==up && (x.getInt()&15)==0)
4017 {
4018 164 check_pound_block(wx,wy);
4019 164 check_pound_block(wx,wy+8);
4020 164 }
4021
5/10
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 1794 times.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 127 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
1968 else if(dir==up && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
4022 {
4023 174 check_pound_block(wx,wy);
4024 174 check_pound_block(wx,wy+8);
4025 174 check_pound_block(wx+8,wy);
4026 174 check_pound_block(wx+8,wy+8);
4027 174 }
4028
4029
4/4
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 1634 times.
✓ Branch 2 taken 258 times.
✓ Branch 3 taken 240 times.
2132 if(dir==down && (x.getInt()&15)==0)
4030 {
4031 240 check_pound_block(wx,wy+wysz-8);
4032 240 check_pound_block(wx,wy+wysz);
4033 240 }
4034
8/10
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 1634 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 152 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 105 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 times.
1892 else if(dir==down && ((x.getInt()&15)==8||diagonalMovement||NO_GRIDLOCK))
4035 {
4036 257 check_pound_block(wx,wy+wysz-8);
4037 257 check_pound_block(wx,wy+wysz);
4038 257 check_pound_block(wx+8,wy+wysz-8);
4039 257 check_pound_block(wx+8,wy+wysz);
4040 257 }
4041
4042
2/2
✓ Branch 0 taken 1429 times.
✓ Branch 1 taken 703 times.
2132 if(dir==left)
4043 {
4044 703 check_pound_block(wx,y+8);
4045 703 check_pound_block(wx+8,y+8);
4046 703 }
4047
4048
2/2
✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 593 times.
2132 if(dir==right)
4049 {
4050 593 check_pound_block(wx+wxsz,y+8);
4051 593 check_pound_block(wx+wxsz-8,y+8);
4052 593 }
4053 2132 }
4054 31330 else return false;
4055
4056 787079 return true;
4057 14308714 }
4058
4059 4047128 void HeroClass::check_slash_block_layer(int32_t bx, int32_t by, int32_t layer)
4060 {
4061
2/2
✓ Branch 0 taken 3847316 times.
✓ Branch 1 taken 199812 times.
4047128 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
4062 {
4063 3847316 return;
4064 }
4065 //keep things inside the screen boundaries
4066 199812 bx=vbound(bx, 0, world_w-1);
4067 199812 by=vbound(by, 0, world_h-1);
4068 199812 int32_t fx=bx;
4069 199812 int32_t fy=by;
4070 //first things first
4071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199812 times.
199812 if(attack!=wSword)
4072 return;
4073
4074
4/6
✓ Branch 0 taken 199812 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 199812 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1984 times.
✓ Branch 5 taken 20732 times.
222528 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
4075
4/4
✓ Branch 0 taken 184460 times.
✓ Branch 1 taken 15352 times.
✓ Branch 2 taken 22716 times.
✓ Branch 3 taken 161744 times.
199812 || (attackclk>SWORDTAPFRAME && tapping))
4076 17336 return;
4077
4078 //find out which combo row/column the coordinates are in
4079 182476 bx = TRUNCATE_TILE(bx);
4080 182476 by = TRUNCATE_TILE(by);
4081
4082 182476 int32_t flag = MAPFLAGL(layer,bx,by);
4083 182476 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4084 182476 int32_t cid = MAPCOMBOL(layer,bx,by);
4085 182476 int32_t type = combobuf[cid].type;
4086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 182476 times.
182476 if(combobuf[cid].only_gentrig)
4087 type = cNONE;
4088
4089 182476 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, layer);
4090 182476 int screen = rpos_handle.screen;
4091 182476 mapscr* s = rpos_handle.scr;
4092 182476 int i = rpos_handle.pos;
4093
4094 182476 bool ignorescreen=false;
4095
4096
4/4
✓ Branch 0 taken 181774 times.
✓ Branch 1 taken 702 times.
✓ Branch 2 taken 181489 times.
✓ Branch 3 taken 285 times.
182476 if((get_bit(screengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4097 182191 return;
4098
4099
3/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 187 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 98 times.
285 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].type==itype_sword) ? itemsbuf[directWpn].level : current_item(itype_sword);
4100
4101
3/4
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 188 times.
285 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid_layer[layer-1],i,1);
4102
1/2
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
285 if(isCuttableNextType(type))
4103 {
4104 285 s->data[i]++;
4105 285 }
4106 else
4107 {
4108 s->data[i] = s->undercombo;
4109 s->cset[i] = s->undercset;
4110 s->sflag[i] = 0;
4111 }
4112
2/8
✓ Branch 0 taken 285 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 285 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
285 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(screen, (screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
4113 {
4114 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4115 sfx(s->secretsfx);
4116 }
4117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 else if(isCuttableItemType(type))
4118 {
4119 285 int32_t it = -1;
4120 285 int32_t thedropset = -1;
4121
4122 //select_dropitem( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) ? (combobuf[MAPCOMBO(bx,by)-1].attributes[1])/10000L : 12, bx, by);
4123
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 254 times.
285 if ( (combobuf[cid].usrflags&cflag2) )
4124 {
4125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(combobuf[cid].usrflags&cflag11)
4126 it = combobuf[cid].attribytes[1];
4127 else
4128 {
4129 31 it = select_dropitem(combobuf[cid].attribytes[1]);
4130 31 thedropset = combobuf[cid].attribytes[1];
4131 }
4132 31 }
4133 else
4134 {
4135 254 it = select_dropitem(12);
4136 254 thedropset = 12;
4137 }
4138
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 96 times.
285 if(it!=-1)
4139 {
4140
4/8
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 96 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 96 times.
✗ Branch 7 not taken.
96 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4141 96 itm->from_dropset = thedropset;
4142 96 items.add(itm);
4143 96 }
4144 285 }
4145
4146 285 putcombo(scrollbuf,bx - viewport.x,by - viewport.y,rpos_handle.data(),rpos_handle.cset());
4147
4148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 285 times.
285 if(get_qr(qr_MORESOUNDS))
4149 {
4150
5/6
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 153 times.
✓ Branch 5 taken 34 times.
285 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4151 {
4152
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if (combobuf[cid].usrflags&cflag3)
4153 {
4154 sfx(combobuf[cid].attribytes[2],pan(bx));
4155 }
4156 34 }
4157 else
4158 {
4159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
251 if (combobuf[cid].usrflags&cflag3)
4160 {
4161 sfx(combobuf[cid].attribytes[2],pan(bx));
4162 }
4163 251 else sfx(QMisc.miscsfx[sfxBUSHGRASS],pan(bx));
4164 }
4165 285 }
4166
4167 285 spawn_decoration_xy(combobuf[cid], fx, fy, bx+8, by+8);
4168 4047128 }
4169
4170 1878466 void HeroClass::check_slash_block(int32_t bx, int32_t by)
4171 {
4172 //first things first
4173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1878466 times.
1878466 if(attack!=wSword)
4174 return;
4175
4176 // keep things inside the screen boundaries
4177 1878466 bx=vbound(bx, 0, world_w-1);
4178 1878466 by=vbound(by, 0, world_h-1);
4179 1878466 int32_t fx=bx;
4180 1878466 int32_t fy=by;
4181
4182
5/6
✓ Branch 0 taken 1878322 times.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 1878322 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9720 times.
✓ Branch 5 taken 210190 times.
2098376 if(z>8||fakez>8 || attackclk==SWORDCHARGEFRAME // is not charging>0, as tapping a wall reduces attackclk but retains charging
4183
4/4
✓ Branch 0 taken 1793030 times.
✓ Branch 1 taken 85292 times.
✓ Branch 2 taken 219910 times.
✓ Branch 3 taken 1573120 times.
1878322 || (attackclk>SWORDTAPFRAME && tapping))
4184 95156 return;
4185
4186 // find out which combo row/column the coordinates are in
4187 1783310 bx = TRUNCATE_TILE(bx);
4188 1783310 by = TRUNCATE_TILE(by);
4189
4190 1783310 int cid = MAPCOMBO(bx,by);
4191 1783310 int cid_ff = MAPFFCOMBO(fx,fy);
4192 1783310 auto current_ffc_handle = getFFCAt(fx,fy);
4193 1783310 newcombo const& cmb = combobuf[cid];
4194 1783310 newcombo const& cmb_ff = combobuf[cid_ff];
4195 1783310 int type = cmb.type;
4196 1783310 int type2 = cmb_ff.type;
4197 1783310 int flag = MAPFLAG(bx,by);
4198 1783310 int flag2 = cmb.flag;
4199 1783310 int flag3 = cmb_ff.flag;
4200
4201 1783310 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, 0);
4202 1783310 int32_t i = rpos_handle.pos;
4203
4204 1783310 bool ignorescreen=false;
4205 1783310 bool ignoreffc=false;
4206
4207
2/2
✓ Branch 0 taken 1757670 times.
✓ Branch 1 taken 25640 times.
1783310 if(get_bit(screengrid, i) != 0)
4208 {
4209 25640 ignorescreen = true;
4210 25640 }
4211
2/2
✓ Branch 0 taken 1757665 times.
✓ Branch 1 taken 5 times.
1757670 else if(cmb.only_gentrig)
4212 5 ignorescreen = true;
4213
4214
4215
3/4
✓ Branch 0 taken 13170 times.
✓ Branch 1 taken 1770140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13170 times.
1783310 if (!current_ffc_handle || current_ffc_handle->ffc->recently_hit)
4216 {
4217 1770140 ignoreffc = true;
4218 1770140 }
4219
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 13151 times.
13170 else if(cmb_ff.only_gentrig)
4220 19 ignoreffc = true;
4221
4222
4/4
✓ Branch 0 taken 1765500 times.
✓ Branch 1 taken 17810 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 1765083 times.
3548439 if(!isCuttableType(type) &&
4223
6/6
✓ Branch 0 taken 3970 times.
✓ Branch 1 taken 1761530 times.
✓ Branch 2 taken 1765129 times.
✓ Branch 3 taken 371 times.
✓ Branch 4 taken 4698 times.
✓ Branch 5 taken 1760431 times.
1765500 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4224 {
4225 1765083 ignorescreen = true;
4226 1765083 }
4227
4228
4/4
✓ Branch 0 taken 1783291 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1783290 times.
3566601 if(!isCuttableType(type2) &&
4229
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1783290 times.
1783291 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4230 {
4231 1783290 ignoreffc = true;
4232 1783290 }
4233
4234
2/2
✓ Branch 0 taken 10822 times.
✓ Branch 1 taken 1772488 times.
1783310 mapscr *s = cur_screen >= 128 ? special_warp_return_scr : rpos_handle.scr;
4235
4236
4/4
✓ Branch 0 taken 80438 times.
✓ Branch 1 taken 1702872 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 80382 times.
1783310 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].type==itype_sword) ? itemsbuf[directWpn].level : current_item(itype_sword);
4237 1783310 byte skipsecrets = 0;
4238
4239
2/2
✓ Branch 0 taken 1776673 times.
✓ Branch 1 taken 6637 times.
1783310 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4240 {
4241
2/2
✓ Branch 0 taken 5639 times.
✓ Branch 1 taken 998 times.
6637 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
4242 {
4243 5639 skipsecrets = 0;
4244 5639 }
4245 998 else skipsecrets = 1;
4246 6637 }
4247
4248
6/6
✓ Branch 0 taken 16644 times.
✓ Branch 1 taken 1766666 times.
✓ Branch 2 taken 993 times.
✓ Branch 3 taken 15651 times.
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 1037 times.
1783310 if(!ignorescreen && (!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)))
4249 {
4250
6/6
✓ Branch 0 taken 1958 times.
✓ Branch 1 taken 14730 times.
✓ Branch 2 taken 1526 times.
✓ Branch 3 taken 432 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 1496 times.
16688 if((flag >= 16)&&(flag <= 31) && !skipsecrets)
4251 {
4252 1496 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4253 1496 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4254 1496 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4255 1496 }
4256
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 15188 times.
15192 else if(flag == mfARMOS_SECRET)
4257 {
4258 4 s->data[i] = s->secretcombo[sSTAIRS];
4259 4 s->cset[i] = s->secretcset[sSTAIRS];
4260 4 s->sflag[i] = s->secretflag[sSTAIRS];
4261 4 sfx(s->secretsfx);
4262 4 }
4263
4/4
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 14792 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 14770 times.
15188 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4264 {
4265
4/4
✓ Branch 0 taken 1083 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 864 times.
✓ Branch 3 taken 374 times.
1282 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4266 {
4267 864 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4268 864 }
4269
4270 374 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
4271 374 }
4272
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14758 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
14770 else if(((flag2 >= 16)&&(flag2 <= 31)))
4273 {
4274 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4275 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4276 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4277 }
4278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14770 times.
14770 else if(flag2 == mfARMOS_SECRET)
4279 {
4280 s->data[i] = s->secretcombo[sSTAIRS];
4281 s->cset[i] = s->secretcset[sSTAIRS];
4282 s->sflag[i] = s->secretflag[sSTAIRS];
4283 sfx(s->secretsfx);
4284 }
4285
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14758 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14758 times.
14770 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4286 {
4287
3/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 12 times.
32 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4288 {
4289 20 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4290 20 }
4291
4292 12 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
4293 12 }
4294 else
4295 {
4296
2/2
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 9679 times.
14758 if(isCuttableNextType(type))
4297 {
4298 5079 s->data[i]++;
4299 5079 }
4300 else
4301 {
4302 9679 s->data[i] = s->undercombo;
4303 9679 s->cset[i] = s->undercset;
4304 9679 s->sflag[i] = 0;
4305 }
4306 }
4307 16644 }
4308
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1766710 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1766710 else if(!ignorescreen && skipsecrets)
4309 {
4310 if(isCuttableNextType(type))
4311 {
4312 s->data[i]++;
4313 }
4314 else
4315 {
4316 s->data[i] = s->undercombo;
4317 s->cset[i] = s->undercset;
4318 s->sflag[i] = 0;
4319 }
4320 }
4321
4322
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1783353 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1783353 times.
1783354 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4323 {
4324
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4325 {
4326 4 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4327 4 }
4328
4329 1 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
4330 1 }
4331
1/2
✓ Branch 0 taken 1783353 times.
✗ Branch 1 not taken.
1783353 else if(!ignoreffc)
4332 {
4333 if(isCuttableNextType(type2))
4334 {
4335 current_ffc_handle->increment_data();
4336 }
4337 else
4338 {
4339 current_ffc_handle->set_data(s->undercombo);
4340 current_ffc_handle->ffc->cset = s->undercset;
4341 }
4342 }
4343
4344
2/2
✓ Branch 0 taken 1766710 times.
✓ Branch 1 taken 16644 times.
1783354 if(!ignorescreen)
4345 {
4346
4/4
✓ Branch 0 taken 5436 times.
✓ Branch 1 taken 11208 times.
✓ Branch 2 taken 290 times.
✓ Branch 3 taken 5146 times.
16644 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
4347
4348
8/8
✓ Branch 0 taken 16339 times.
✓ Branch 1 taken 305 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 16384 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 305 times.
✓ Branch 6 taken 45 times.
✓ Branch 7 taken 215 times.
16644 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
4349 {
4350
4/8
✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 260 times.
✗ Branch 7 not taken.
260 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4351 260 sfx(s->secretsfx);
4352 260 }
4353
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 15961 times.
16384 else if(isCuttableItemType(type))
4354 {
4355 15961 int32_t it = -1;
4356 15961 int32_t thedropset = -1;
4357
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 15913 times.
15961 if ( (cmb.usrflags&cflag2) ) //specific dropset or item
4358 {
4359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if ( cmb.usrflags&cflag11 )
4360 {
4361 it = cmb.attribytes[1];
4362 }
4363 else
4364 {
4365 48 it = select_dropitem(cmb.attribytes[1]);
4366 48 thedropset = cmb.attribytes[1];
4367 }
4368 48 }
4369 else
4370 {
4371 15913 it = select_dropitem(12);
4372 15913 thedropset = 12;
4373 }
4374
4375
2/2
✓ Branch 0 taken 11158 times.
✓ Branch 1 taken 4803 times.
15961 if(it!=-1)
4376 {
4377
4/8
✓ Branch 0 taken 4803 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4803 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4803 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4803 times.
✗ Branch 7 not taken.
4803 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4378 4803 itm->from_dropset = thedropset;
4379 4803 items.add(itm);
4380 4803 }
4381 15961 }
4382
4383 16644 putcombo(scrollbuf, bx - viewport.x, by - viewport.y, s->data[i], s->cset[i]);
4384
4385
2/2
✓ Branch 0 taken 8270 times.
✓ Branch 1 taken 8374 times.
16644 if(get_qr(qr_MORESOUNDS))
4386 {
4387
6/6
✓ Branch 0 taken 6788 times.
✓ Branch 1 taken 1586 times.
✓ Branch 2 taken 4743 times.
✓ Branch 3 taken 2045 times.
✓ Branch 4 taken 4115 times.
✓ Branch 5 taken 628 times.
8374 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4388 {
4389
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 44 times.
628 if (cmb.usrflags&cflag3)
4390 {
4391 44 sfx(cmb.attribytes[2],pan(bx));
4392 44 }
4393 628 }
4394 else
4395 {
4396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7746 times.
7746 if (cmb.usrflags&cflag3)
4397 {
4398 sfx(cmb.attribytes[2],pan(bx));
4399 }
4400 7746 else sfx(QMisc.miscsfx[sfxBUSHGRASS],pan(bx));
4401 }
4402 8374 }
4403
4404 16644 spawn_decoration_xy(cmb, fx, fy, bx+8, by+8);
4405 16644 }
4406
4407
2/2
✓ Branch 0 taken 1783353 times.
✓ Branch 1 taken 1 times.
1783354 if(!ignoreffc)
4408 {
4409
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS))
4410 {
4411 1 current_ffc_handle->ffc->recently_hit = true;
4412 1 }
4413
4414
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(isCuttableItemType(type2))
4415 {
4416 int32_t it=-1;
4417 int32_t thedropset=-1;
4418 if ( (cmb_ff.usrflags&cflag2) )
4419 {
4420 if(cmb_ff.usrflags&cflag11)
4421 it = cmb_ff.attribytes[1];
4422 else
4423 {
4424 it = select_dropitem(cmb_ff.attribytes[1]);
4425 thedropset = cmb_ff.attribytes[1];
4426 }
4427 }
4428 else
4429 {
4430 if(get_qr(qr_HARDCODED_FFC_BUSH_DROPS))
4431 {
4432 int32_t r=zc_oldrand()%100;
4433
4434 if(r<15)
4435 it=iHeart; // 15%
4436 else if(r<35)
4437 it=iRupy; // 20%
4438 }
4439 else
4440 {
4441 it = select_dropitem(12);
4442 thedropset = 12;
4443 }
4444 }
4445
4446 if(it!=-1 && itemsbuf[it].type != itype_misc) // Don't drop non-gameplay items
4447 {
4448 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4449 itm->from_dropset = thedropset;
4450 items.add(itm);
4451 }
4452 }
4453
4454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(get_qr(qr_MORESOUNDS))
4455 {
4456
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
1 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4457 {
4458
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (cmb_ff.usrflags&cflag3)
4459 {
4460 sfx(cmb_ff.attribytes[2],pan(bx));
4461 }
4462 1 }
4463 else
4464 {
4465 if (cmb_ff.usrflags&cflag3)
4466 {
4467 sfx(cmb_ff.attribytes[2],pan(bx));
4468 }
4469 else sfx(QMisc.miscsfx[sfxBUSHGRASS],pan(bx));
4470 }
4471 1 }
4472
4473 1 auto& ffc = *current_ffc_handle->ffc;
4474 1 spawn_decoration_xy(cmb_ff, fx, fy, ffc.x+(ffc.hit_width / 2), ffc.y+(ffc.hit_height / 2));
4475 1 }
4476 1878510 }
4477
4478 25566117 void HeroClass::check_wpn_triggers(int32_t bx, int32_t by, weapon *w)
4479 {
4480 25566117 bx=vbound(bx, 0, world_w-1);
4481 25566117 by=vbound(by, 0, world_h-1);
4482
5/30
✓ Branch 0 taken 3120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 648 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 201384 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✓ Branch 26 taken 25356301 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 4664 times.
✗ Branch 29 not taken.
25566117 switch(w->useweapon)
4483 {
4484 case wArrow:
4485 3120 trigger_secrets_if_flag(bx,by,mfARROW,true);
4486 3120 trigger_secrets_if_flag(bx,by,mfSARROW,true);
4487 3120 trigger_secrets_if_flag(bx,by,mfGARROW,true);
4488 3120 break;
4489 case wBeam:
4490 for(int32_t i = 0; i <4; i++) trigger_secrets_if_flag(bx,by,mfSWORDBEAM+i,true);
4491 break;
4492 case wHookshot:
4493 trigger_secrets_if_flag(bx,by,mfHOOKSHOT,true);
4494 break;
4495 case wBrang:
4496 for(int32_t i = 0; i <3; i++) trigger_secrets_if_flag(bx,by,mfBRANG+i,true);
4497 break;
4498 case wMagic:
4499 trigger_secrets_if_flag(bx,by,mfWANDMAGIC,true);
4500 break;
4501 case wRefMagic:
4502 trigger_secrets_if_flag(bx,by,mfWANDMAGIC,true);
4503 break;
4504 case wRefBeam:
4505 for(int32_t i = 0; i <4; i++) trigger_secrets_if_flag(bx,by,mfSWORDBEAM+i,true);
4506 break;
4507 //reflected magic needs to happen in mirrors:
4508 //
4509 //trigger_secrets_if_flag(bx,by,mfREFMAGIC,true)
4510 case wRefFireball:
4511 trigger_secrets_if_flag(bx,by,mfREFFIREBALL,true);
4512 break;
4513 case wBomb:
4514 648 trigger_secrets_if_flag(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfBOMB,true);
4515 648 break;
4516
4517 case wSBomb:
4518 trigger_secrets_if_flag(bx+w->txsz,by+tysz+(isSideViewGravity()?2:-3),mfSBOMB,true);
4519 break;
4520
4521 case wFire:
4522 201384 trigger_secrets_if_flag(bx,by,mfANYFIRE,true);
4523 201384 trigger_secrets_if_flag(bx,by,mfSTRONGFIRE,true);
4524 201384 trigger_secrets_if_flag(bx,by,mfMAGICFIRE,true);
4525 201384 break;
4526
4527 case wScript1:
4528 break;
4529 case wScript2:
4530 break;
4531 case wScript3:
4532 break;
4533 case wScript4:
4534 break;
4535 case wScript5:
4536 break;
4537 case wScript6:
4538 break;
4539 case wScript7:
4540 break;
4541 case wScript8:
4542 break;
4543 case wScript9:
4544 break;
4545 case wScript10:
4546 break;
4547 case wIce:
4548 break;
4549 case wCByrna:
4550 break;
4551 case wWhistle:
4552 break;
4553 case wSSparkle:
4554 case wFSparkle:
4555 break;
4556 case wWind:
4557 break;
4558 case wBait:
4559 break;
4560 case wFlame:
4561 case wThrown:
4562 case wBombos:
4563 case wEther:
4564 case wQuake:
4565 case wSwordLA:
4566 case wSword180:
4567 case wStomp:
4568 break;
4569 case wSword:
4570 case wWand:
4571 //case wCandle:
4572 case wHSHandle:
4573 case wLitBomb:
4574 case wLitSBomb:
4575 4664 break;
4576 25356301 default: break;
4577
4578 }
4579 25566117 }
4580
4581 51132234 void HeroClass::check_slash_block_layer2(int32_t bx, int32_t by, weapon *w, int32_t layer)
4582 {
4583
2/2
✓ Branch 0 taken 2128078 times.
✓ Branch 1 taken 49004156 times.
51132234 if(!(get_qr(qr_BUSHESONLAYERS1AND2)))
4584 {
4585 49004156 return;
4586 }
4587 //keep things inside the screen boundaries
4588 2128078 bx=vbound(bx, 0, world_w-1);
4589 2128078 by=vbound(by, 0, world_h-1);
4590 2128078 int32_t fx=bx;
4591 2128078 int32_t fy=by;
4592 //first things first
4593
2/2
✓ Branch 0 taken 2121246 times.
✓ Branch 1 taken 6832 times.
2128078 if(w->useweapon != wSword)
4594 2121246 return;
4595
4596 //find out which combo row/column the coordinates are in
4597 6832 bx = TRUNCATE_TILE(bx);
4598 6832 by = TRUNCATE_TILE(by);
4599
4600
4601 6832 int32_t flag = MAPFLAGL(layer,bx,by);
4602 6832 int32_t flag2 = MAPCOMBOFLAGL(layer,bx,by);
4603 6832 int32_t cid = MAPCOMBOL(layer,bx,by);
4604 6832 int32_t type = combobuf[cid].type;
4605
1/2
✓ Branch 0 taken 6832 times.
✗ Branch 1 not taken.
6832 if(combobuf[cid].only_gentrig)
4606 type = cNONE;
4607
4608 6832 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, layer);
4609 6832 int32_t i = rpos_handle.pos;
4610
4611 // bool checked = w->rposes_checked.contains({rpos_handle.layer, rpos_handle.rpos});
4612
3/4
✓ Branch 0 taken 6832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6826 times.
✓ Branch 3 taken 6 times.
6832 if((get_bit(w->wscreengrid_layer[layer-1], i) != 0) || (!isCuttableType(type)))
4613 {
4614 6826 return;
4615 }
4616
4617 6 mapscr* s = rpos_handle.scr;
4618
4619
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].type==itype_sword) ? itemsbuf[directWpn].level : current_item(itype_sword);
4620
4621 {
4622
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid_layer[layer-1],i,1);
4623
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 if(isCuttableNextType(type) || isCuttableNextType(type))
4624 {
4625 6 s->data[i]++;
4626 6 }
4627 else
4628 {
4629 s->data[i] = s->undercombo;
4630 s->cset[i] = s->undercset;
4631 s->sflag[i] = 0;
4632 }
4633
2/8
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
4634 {
4635 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4636 sfx(s->secretsfx);
4637 }
4638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(isCuttableItemType(type))
4639 {
4640 6 int32_t it = -1;
4641 6 int32_t thedropset = -1;
4642
4643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( (combobuf[cid].usrflags&cflag2) )
4644 {
4645 if(combobuf[cid].usrflags&cflag11)
4646 it = combobuf[cid].attribytes[1];
4647 else
4648 {
4649 it = select_dropitem(combobuf[cid].attribytes[1]);
4650 thedropset = combobuf[cid].attribytes[1];
4651 }
4652 }
4653 else
4654 {
4655 6 it = select_dropitem(12);
4656 6 thedropset = 12;
4657 }
4658
4659
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if(it!=-1)
4660 {
4661
4/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
2 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4662 2 itm->from_dropset = thedropset;
4663 2 items.add(itm);
4664 2 }
4665 6 }
4666
4667 6 putcombo(scrollbuf,bx - viewport.x, by - viewport.y,rpos_handle.data(),rpos_handle.cset());
4668
4669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if(get_qr(qr_MORESOUNDS))
4670 {
4671
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4672 {
4673 if (combobuf[cid].usrflags&cflag3)
4674 {
4675 sfx(combobuf[cid].attribytes[2],pan(bx));
4676 }
4677 }
4678 else
4679 {
4680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (combobuf[cid].usrflags&cflag3)
4681 {
4682 sfx(combobuf[cid].attribytes[2],pan(bx));
4683 }
4684 6 else sfx(QMisc.miscsfx[sfxBUSHGRASS],pan(bx));
4685 }
4686 6 }
4687
4688
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4689
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(decotype > 3) decotype = 0;
4690
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4691
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6 switch(decotype)
4692 {
4693 case -2: break; //nothing
4694 case -1:
4695 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4696 break;
4697
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4698 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4699 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4700 }
4701
4702 }
4703
4704 51132234 }
4705
4706 25566227 void HeroClass::check_slash_block2(int32_t bx, int32_t by, weapon *w)
4707 {
4708 //keep things inside the screen boundaries
4709 25566227 bx=vbound(bx, 0, world_w-1);
4710 25566227 by=vbound(by, 0, world_h-1);
4711 25566227 int32_t fx=bx;
4712 25566227 int32_t fy=by;
4713 25566227 int32_t cid = MAPCOMBO(bx,by);
4714
4715 //find out which combo row/column the coordinates are in
4716 25566227 bx = TRUNCATE_TILE(bx);
4717 25566227 by = TRUNCATE_TILE(by);
4718
4719 25566227 int32_t type = COMBOTYPE(bx,by);
4720 25566227 int32_t type2 = FFCOMBOTYPE(fx,fy);
4721 25566227 int32_t flag = MAPFLAG(bx,by);
4722 25566227 int32_t flag2 = MAPCOMBOFLAG(bx,by);
4723 25566227 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
4724
2/2
✓ Branch 0 taken 25566013 times.
✓ Branch 1 taken 214 times.
25566227 if(combobuf[cid].only_gentrig)
4725 214 type = cNONE;
4726 25566227 byte dontignore = 0;
4727 25566227 byte dontignoreffc = 0;
4728
4729
4/4
✓ Branch 0 taken 430486 times.
✓ Branch 1 taken 25135741 times.
✓ Branch 2 taken 429888 times.
✓ Branch 3 taken 598 times.
25566227 if (isCuttableType(type) && FindComboTriggerMatch(w, cid) > -1)
4730 {
4731 598 dontignore = 1;
4732 598 }
4733
4/4
✓ Branch 0 taken 25561453 times.
✓ Branch 1 taken 4774 times.
✓ Branch 2 taken 25560855 times.
✓ Branch 3 taken 598 times.
25566227 if(w->useweapon != wSword && !dontignore) return;
4734
4735 5372 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, 0);
4736 5372 int32_t i = rpos_handle.pos;
4737
4738
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5351 times.
5372 if (get_bit(w->wscreengrid,i)) return;
4739
4740 5351 bool ignorescreen=false;
4741 5351 bool ignoreffc=false;
4742
4743
1/2
✓ Branch 0 taken 5351 times.
✗ Branch 1 not taken.
5351 if(get_bit(w->wscreengrid, i) != 0)
4744 {
4745 ignorescreen = true; dontignore = 0;
4746 }
4747
4748 5351 auto current_ffc_handle = getFFCAt(fx,fy);
4749
4750
3/4
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 5085 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266 times.
5351 if (!current_ffc_handle || current_ffc_handle->ffc->recently_hit)
4751 {
4752 5085 ignoreffc = true;
4753 5085 }
4754
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 else if(combobuf[current_ffc_handle->data()].only_gentrig)
4755 type2 = cNONE;
4756
3/4
✓ Branch 0 taken 4631 times.
✓ Branch 1 taken 720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4631 times.
9982 if(!isCuttableType(type) &&
4757
5/6
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 4483 times.
✓ Branch 2 taken 4631 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 718 times.
✓ Branch 5 taken 3913 times.
4631 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
4758 {
4759 4631 ignorescreen = true;
4760 4631 }
4761
4762
3/4
✓ Branch 0 taken 5241 times.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5241 times.
10592 if(!isCuttableType(type2) &&
4763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5241 times.
5241 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
4764 {
4765 5241 ignoreffc = true;
4766 5241 }
4767
4768
2/2
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 5241 times.
5351 mapscr *s = cur_screen >= 128 ? special_warp_return_scr : rpos_handle.scr;
4769
4770
4/4
✓ Branch 0 taken 4851 times.
✓ Branch 1 taken 316 times.
✓ Branch 2 taken 233 times.
✓ Branch 3 taken 4618 times.
5351 int32_t sworditem = (directWpn>-1 && itemsbuf[directWpn].type==itype_sword) ? itemsbuf[directWpn].level : current_item(itype_sword);
4771 5167 byte skipsecrets = 0;
4772
2/2
✓ Branch 0 taken 4630 times.
✓ Branch 1 taken 501 times.
5167 if ( isNextType(type) ) //->Next combos should not trigger secrets. Their child combo, may want to do that! -Z 17th December, 2019
4773 {
4774
2/2
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 3 times.
501 if (get_qr(qr_OLD_SLASHNEXT_SECRETS))
4775 {
4776 498 skipsecrets = 0;
4777 498 }
4778 3 else skipsecrets = 1;
4779 501 }
4780
6/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 5128 times.
✓ Branch 2 taken 4631 times.
✓ Branch 3 taken 4628 times.
✓ Branch 4 taken 4631 times.
✓ Branch 5 taken 5125 times.
5131 if((!skipsecrets || !get_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS)) && (!ignorescreen || dontignore))
4781 {
4782
3/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 608 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9756 if((flag >= 16)&&(flag <= 31)&&!skipsecrets)
4783 {
4784 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4785 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4786 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4787 }
4788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(flag == mfARMOS_SECRET)
4789 {
4790 s->data[i] = s->secretcombo[sSTAIRS];
4791 s->cset[i] = s->secretcset[sSTAIRS];
4792 s->sflag[i] = s->secretflag[sSTAIRS];
4793 sfx(s->secretsfx);
4794 }
4795
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
610 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
4796 {
4797 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4798 {
4799 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4800 }
4801
4802 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
4803 }
4804
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
610 else if(((flag2 >= 16)&&(flag2 <= 31)))
4805 {
4806 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
4807 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
4808 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
4809 }
4810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(flag2 == mfARMOS_SECRET)
4811 {
4812 s->data[i] = s->secretcombo[sSTAIRS];
4813 s->cset[i] = s->secretcset[sSTAIRS];
4814 s->sflag[i] = s->secretflag[sSTAIRS];
4815 sfx(s->secretsfx);
4816 }
4817
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
610 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
4818 {
4819 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4820 {
4821 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4822 }
4823
4824 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
4825 }
4826 else
4827 {
4828
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 109 times.
610 if(isCuttableNextType(type))
4829 {
4830 501 s->data[i]++;
4831 501 }
4832 else
4833 {
4834 109 s->data[i] = s->undercombo;
4835 109 s->cset[i] = s->undercset;
4836 109 s->sflag[i] = 0;
4837 }
4838 }
4839 610 }
4840
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4631 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4631 else if(skipsecrets && (!ignorescreen || dontignore))
4841 {
4842 if(isCuttableNextType(type))
4843 {
4844 s->data[i]++;
4845 }
4846 else
4847 {
4848 s->data[i] = s->undercombo;
4849 s->cset[i] = s->undercset;
4850 s->sflag[i] = 0;
4851 }
4852 }
4853
4854
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5241 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5241 times.
5241 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
4855 {
4856 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
4857 {
4858 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
4859 }
4860
4861 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
4862 }
4863
1/2
✓ Branch 0 taken 5241 times.
✗ Branch 1 not taken.
5241 else if(!ignoreffc)
4864 {
4865 if(isCuttableNextType(type2))
4866 {
4867 current_ffc_handle->increment_data();
4868 }
4869 else
4870 {
4871 current_ffc_handle->set_data(s->undercombo);
4872 current_ffc_handle->ffc->cset = s->undercset;
4873 }
4874 }
4875
4876
3/4
✓ Branch 0 taken 4631 times.
✓ Branch 1 taken 610 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4631 times.
5241 if(!ignorescreen || dontignore)
4877 {
4878
3/4
✓ Branch 0 taken 425 times.
✓ Branch 1 taken 185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 425 times.
610 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(w->wscreengrid,i,1);
4879
4880
2/8
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 610 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
610 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
4881 {
4882 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
4883 sfx(s->secretsfx);
4884 }
4885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 else if(isCuttableItemType(type))
4886 {
4887 610 int32_t it = -1;
4888 610 int32_t thedropset = -1;
4889
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 601 times.
610 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
4890 {
4891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if ( combobuf[cid].usrflags&cflag11 )
4892 {
4893 it = combobuf[cid].attribytes[1];
4894 }
4895 else
4896 {
4897 9 it = select_dropitem(combobuf[cid].attribytes[1]);
4898 9 thedropset = combobuf[cid].attribytes[1];
4899 }
4900 9 }
4901 else
4902 {
4903 601 it = select_dropitem(12);
4904 601 thedropset = 12;
4905 }
4906
4907
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 198 times.
610 if(it!=-1)
4908 {
4909
4/8
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 198 times.
✗ Branch 7 not taken.
198 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4910 198 itm->from_dropset = thedropset;
4911 198 items.add(itm);
4912 198 }
4913 610 }
4914
4915
4916 610 putcombo(scrollbuf,bx-viewport.x,by-viewport.y,s->data[i],s->cset[i]);
4917
4918
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if(get_qr(qr_MORESOUNDS))
4919 {
4920
5/6
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 179 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 100 times.
✓ Branch 4 taken 331 times.
✗ Branch 5 not taken.
610 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
4921 {
4922 if (combobuf[cid].usrflags&cflag3)
4923 {
4924 sfx(combobuf[cid].attribytes[2],pan(bx));
4925 }
4926 }
4927 else
4928 {
4929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 610 times.
610 if (combobuf[cid].usrflags&cflag3)
4930 {
4931 sfx(combobuf[cid].attribytes[2],pan(bx));
4932 }
4933 610 else sfx(QMisc.miscsfx[sfxBUSHGRASS],pan(bx));
4934 }
4935 610 }
4936
4937
3/4
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 598 times.
✗ Branch 3 not taken.
610 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
4938
1/2
✓ Branch 0 taken 610 times.
✗ Branch 1 not taken.
610 if(decotype > 3) decotype = 0;
4939
6/8
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
610 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
4940
3/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 501 times.
✓ Branch 4 taken 100 times.
✓ Branch 5 taken 9 times.
610 switch(decotype)
4941 {
4942 case -2: break; //nothing
4943 case -1:
4944 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
4945 break;
4946
3/6
✓ Branch 0 taken 501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 501 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 501 times.
✗ Branch 5 not taken.
501 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
4947
3/6
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
100 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
4948
3/6
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
9 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
4949 }
4950 610 }
4951
4952
1/2
✓ Branch 0 taken 5241 times.
✗ Branch 1 not taken.
5241 if(!ignoreffc)
4953 {
4954 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS))
4955 {
4956 current_ffc_handle->ffc->recently_hit = true;
4957 }
4958
4959 if(isCuttableItemType(type2))
4960 {
4961 int32_t it=-1;
4962 int32_t thedropset=-1;
4963 if ( (combobuf[cid].usrflags&cflag2) )
4964 {
4965 if(combobuf[cid].usrflags&cflag11)
4966 it = combobuf[cid].attribytes[1];
4967 else
4968 {
4969 it = select_dropitem(combobuf[cid].attribytes[1]);
4970 thedropset = combobuf[cid].attribytes[1];
4971 }
4972 }
4973 else
4974 {
4975 int32_t r=zc_oldrand()%100;
4976
4977 if(r<15)
4978 {
4979 it=iHeart; // 15%
4980 }
4981 else if(r<35)
4982 {
4983 it=iRupy; // 20%
4984 }
4985 }
4986
4987 if(it!=-1 && itemsbuf[it].type != itype_misc) // Don't drop non-gameplay items
4988 {
4989 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
4990 itm->from_dropset = thedropset;
4991 items.add(itm);
4992 }
4993 }
4994
4995 if(get_qr(qr_MORESOUNDS))
4996 {
4997 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
4998 {
4999 if (combobuf[cid].usrflags&cflag3)
5000 {
5001 sfx(combobuf[cid].attribytes[2],pan(bx));
5002 }
5003 }
5004 else
5005 {
5006 if (combobuf[cid].usrflags&cflag3)
5007 {
5008 sfx(combobuf[cid].attribytes[2],pan(bx));
5009 }
5010 else sfx(QMisc.miscsfx[sfxBUSHGRASS],pan(bx));
5011 }
5012 }
5013
5014 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5015 if(decotype > 3) decotype = 0;
5016 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5017 switch(decotype)
5018 {
5019 case -2: break; //nothing
5020 case -1:
5021 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5022 break;
5023 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5024 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5025 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5026 }
5027 }
5028 25566117 }
5029
5030 25566117 void HeroClass::check_wand_block2(int32_t bx, int32_t by, weapon *w)
5031 {
5032 25566117 byte dontignore = 0;
5033 25566117 byte dontignoreffc = 0;
5034
5035 //keep things inside the screen boundaries
5036 25566117 bx=vbound(bx, 0, world_w-1);
5037 25566117 by=vbound(by, 0, world_h-1);
5038 25566117 int32_t fx=bx;
5039 25566117 int32_t fy=by;
5040 25566117 int32_t cid = MAPCOMBO(bx,by);
5041
5042 //Z_scripterrlog("check_wand_block2 MatchComboTrigger() returned: %d\n", );
5043
3/4
✓ Branch 0 taken 25566117 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✓ Branch 3 taken 25563355 times.
25566117 if(w->useweapon != wWand && FindComboTriggerMatch (w, cid) < 0) return;
5044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2762 times.
2762 if ( FindComboTriggerMatch (w, cid) != -1 ) dontignore = 1;
5045
5046 //first things first
5047
2/4
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✗ Branch 3 not taken.
2762 if(z>8||fakez>8) return;
5048
5049 //find out which combo row/column the coordinates are in
5050 2762 bx = TRUNCATE_TILE(bx);
5051 2762 by = TRUNCATE_TILE(by);
5052
5053 2762 int32_t flag = MAPFLAG(bx,by);
5054 2762 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5055 2762 int32_t flag3=0;
5056 2762 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5057 2762 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5058 2762 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5059 2762 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5060
5061
4/8
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2762 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2762 times.
2762 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5062 flag3=mfWAND;
5063
5064
4/8
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2762 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2762 times.
2762 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5065 flag3=mfSTRIKE;
5066
5067
6/12
✓ Branch 0 taken 2762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2762 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2762 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2762 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2762 times.
2762 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5068 2762 return;
5069
5070 if((trigger_secrets_if_flag(bx,by,mfWAND,true)==false)&&(trigger_secrets_if_flag(bx,by,mfSTRIKE,true)==false))
5071 {
5072 if(flag3==mfWAND||flag3==mfSTRIKE)
5073 {
5074 trigger_secrets_if_flag(fx,fy,mfWAND,true);
5075 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
5076 }
5077 }
5078
5079 if(dontignore)
5080 trigger_secrets_if_flag(bx,by,mfWAND,true);
5081 25566117 }
5082
5083 void HeroClass::check_slash_block(weapon *w)
5084 {
5085 //first things
5086
5087 int32_t par_item = w->parentitem;
5088 int32_t usewpn = -1;
5089 if ( par_item > -1 )
5090 {
5091 usewpn = itemsbuf[par_item].weap_data.imitate_weapon;
5092 }
5093 else if ( par_item == -1 && w->ScriptGenerated )
5094 {
5095 usewpn = w->useweapon;
5096 }
5097 if(usewpn != wSword) return;
5098
5099
5100 int32_t bx = 0, by = 0;
5101 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
5102 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
5103 //keep things inside the screen boundaries
5104 bx=vbound(bx, 0, world_w-1);
5105 by=vbound(by, 0, world_h-1);
5106 int32_t fx=bx;
5107 int32_t fy=by;
5108
5109 int32_t cid = MAPCOMBO(bx,by);
5110
5111 //find out which combo row/column the coordinates are in
5112 bx = TRUNCATE_TILE(bx);
5113 by = TRUNCATE_TILE(by);
5114
5115 int32_t type = COMBOTYPE(bx,by);
5116 int32_t type2 = FFCOMBOTYPE(fx,fy);
5117 int32_t flag = MAPFLAG(bx,by);
5118 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5119 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5120 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, 0);
5121 int32_t i = rpos_handle.pos;
5122
5123 if(combobuf[cid].only_gentrig)
5124 type = cNONE;
5125 bool ignorescreen=false;
5126 bool ignoreffc=false;
5127
5128 if(get_bit(screengrid, i) != 0)
5129 {
5130 ignorescreen = true;
5131 }
5132
5133 auto current_ffc_handle = getFFCAt(fx,fy);
5134
5135 if (!current_ffc_handle || current_ffc_handle->ffc->recently_hit)
5136 {
5137 ignoreffc = true;
5138 }
5139 else if(combobuf[current_ffc_handle->data()].only_gentrig)
5140 type2 = cNONE;
5141 if(!isCuttableType(type) &&
5142 (flag<mfSWORD || flag>mfXSWORD) && flag!=mfSTRIKE && (flag2<mfSWORD || flag2>mfXSWORD) && flag2!=mfSTRIKE)
5143 {
5144 ignorescreen = true;
5145 }
5146
5147 if(!isCuttableType(type2) &&
5148 (flag3<mfSWORD || flag3>mfXSWORD) && flag3!=mfSTRIKE)
5149 {
5150 ignoreffc = true;
5151 }
5152
5153 mapscr *s = cur_screen >= 128 ? special_warp_return_scr : rpos_handle.scr;
5154
5155 int32_t sworditem = (par_item >-1 ? itemsbuf[par_item].level : current_item(itype_sword)); //Get the level of the item, else the highest sword level in inventory.
5156
5157 if(!ignorescreen)
5158 {
5159 if((flag >= 16)&&(flag <= 31))
5160 {
5161 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5162 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5163 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5164 }
5165 else if(flag == mfARMOS_SECRET)
5166 {
5167 s->data[i] = s->secretcombo[sSTAIRS];
5168 s->cset[i] = s->secretcset[sSTAIRS];
5169 s->sflag[i] = s->secretflag[sSTAIRS];
5170 sfx(s->secretsfx);
5171 }
5172 else if(((flag>=mfSWORD&&flag<=mfXSWORD)||(flag==mfSTRIKE)))
5173 {
5174 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5175 {
5176 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
5177 }
5178
5179 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5180 }
5181 else if(((flag2 >= 16)&&(flag2 <= 31)))
5182 {
5183 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5184 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5185 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5186 }
5187 else if(flag2 == mfARMOS_SECRET)
5188 {
5189 s->data[i] = s->secretcombo[sSTAIRS];
5190 s->cset[i] = s->secretcset[sSTAIRS];
5191 s->sflag[i] = s->secretflag[sSTAIRS];
5192 sfx(s->secretsfx);
5193 }
5194 else if(((flag2>=mfSWORD&&flag2<=mfXSWORD)||(flag2==mfSTRIKE)))
5195 {
5196 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5197 {
5198 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
5199 }
5200
5201 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5202 }
5203 else
5204 {
5205 if(isCuttableNextType(type))
5206 {
5207 s->data[i]++;
5208 }
5209 else
5210 {
5211 s->data[i] = s->undercombo;
5212 s->cset[i] = s->undercset;
5213 s->sflag[i] = 0;
5214 }
5215 }
5216 }
5217
5218 if(((flag3>=mfSWORD&&flag3<=mfXSWORD)||(flag3==mfSTRIKE)) && !ignoreffc)
5219 {
5220 for(int32_t i2=0; i2<=zc_min(sworditem-1,3); i2++)
5221 {
5222 trigger_secrets_if_flag(bx,by,mfSWORD+i2,true);
5223 }
5224
5225 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
5226 }
5227 else if(!ignoreffc)
5228 {
5229 if(isCuttableNextType(type2))
5230 {
5231 current_ffc_handle->increment_data();
5232 }
5233 else
5234 {
5235 current_ffc_handle->set_data(s->undercombo);
5236 current_ffc_handle->set_cset(s->undercset);
5237 }
5238 }
5239
5240 if(!ignorescreen)
5241 {
5242 if(!isTouchyType(type) && !get_qr(qr_CONT_SWORD_TRIGGERS)) set_bit(screengrid,i,1);
5243
5244 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
5245 {
5246 items.add(new item((zfix)bx, (zfix)by,(zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5247 sfx(s->secretsfx);
5248 }
5249 else if(isCuttableItemType(type))
5250 {
5251 int32_t it = -1;
5252 int32_t thedropset = -1;
5253 if ( (combobuf[cid].usrflags&cflag2) ) //specific dropset or item
5254 {
5255 if ( combobuf[cid].usrflags&cflag11 )
5256 {
5257 it = combobuf[cid].attribytes[1];
5258 }
5259 else
5260 {
5261 it = select_dropitem(combobuf[cid].attribytes[1]);
5262 thedropset = combobuf[cid].attribytes[1];
5263 }
5264 }
5265 else
5266 {
5267 it = select_dropitem(12);
5268 thedropset = 12;
5269 }
5270
5271 if(it!=-1)
5272 {
5273 item* itm = (new item((zfix)bx, (zfix)by,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5274 itm->from_dropset = thedropset;
5275 items.add(itm);
5276 }
5277 }
5278
5279 putcombo(scrollbuf,bx-viewport.x,by-viewport.y,s->data[i],s->cset[i]);
5280
5281 if(get_qr(qr_MORESOUNDS))
5282 {
5283 if (!isBushType(type) && !isFlowersType(type) && !isGrassType(type))
5284 {
5285 if (combobuf[cid].usrflags&cflag3)
5286 {
5287 sfx(combobuf[cid].attribytes[2],pan(bx));
5288 }
5289 }
5290 else
5291 {
5292 if (combobuf[cid].usrflags&cflag3)
5293 {
5294 sfx(combobuf[cid].attribytes[2],pan(bx));
5295 }
5296 else sfx(QMisc.miscsfx[sfxBUSHGRASS],pan(bx));
5297 }
5298 }
5299
5300 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5301 if(decotype > 3) decotype = 0;
5302 if(!decotype) decotype = (isBushType(type) ? 1 : (isFlowersType(type) ? 2 : (isGrassType(type) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5303 switch(decotype)
5304 {
5305 case -2: break; //nothing
5306 case -1:
5307 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5308 break;
5309 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5310 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5311 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5312 }
5313 }
5314
5315 if(!ignoreffc)
5316 {
5317 if(!isTouchyType(type2) && !get_qr(qr_CONT_SWORD_TRIGGERS))
5318 {
5319 current_ffc_handle->ffc->recently_hit = true;
5320 }
5321
5322 if(isCuttableItemType(type2))
5323 {
5324 int32_t it=-1;
5325 int32_t thedropset = -1;
5326 if ( (combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag2) )
5327 {
5328 if(combobuf[MAPCOMBO(bx,by)-1].usrflags&cflag11)
5329 it = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5330 else
5331 {
5332 thedropset = combobuf[MAPCOMBO(bx,by)-1].attribytes[1];
5333 it = select_dropitem(thedropset);
5334 }
5335 }
5336 else
5337 {
5338 it = select_dropitem(12);
5339 thedropset = 12;
5340 }
5341
5342 if(it!=-1 && itemsbuf[it].type != itype_misc) // Don't drop non-gameplay items
5343 {
5344 item* itm = (new item((zfix)fx, (zfix)fy,(zfix)0, it, ipBIGRANGE + ipTIMER, 0));
5345 itm->from_dropset = thedropset;
5346 items.add(itm);
5347 }
5348 }
5349
5350 if(get_qr(qr_MORESOUNDS))
5351 {
5352 if (!isBushType(type2) && !isFlowersType(type2) && !isGrassType(type2))
5353 {
5354 if (combobuf[cid].usrflags&cflag3)
5355 {
5356 sfx(combobuf[cid].attribytes[2],pan(bx));
5357 }
5358 }
5359 else
5360 {
5361 if (combobuf[cid].usrflags&cflag3)
5362 {
5363 sfx(combobuf[cid].attribytes[2],pan(bx));
5364 }
5365 else sfx(QMisc.miscsfx[sfxBUSHGRASS],pan(bx));
5366 }
5367 }
5368
5369 int16_t decotype = (combobuf[cid].usrflags & cflag1) ? ((combobuf[cid].usrflags & cflag10) ? (combobuf[cid].attribytes[0]) : (-1)) : (0);
5370 if(decotype > 3) decotype = 0;
5371 if(!decotype) decotype = (isBushType(type2) ? 1 : (isFlowersType(type2) ? 2 : (isGrassType(type2) ? 3 : ((combobuf[cid].usrflags & cflag1) ? -1 : -2))));
5372 switch(decotype)
5373 {
5374 case -2: break; //nothing
5375 case -1:
5376 decorations.add(new comboSprite((zfix)fx, (zfix)fy, dCOMBOSPRITE, 0, combobuf[cid].attribytes[0]));
5377 break;
5378 case 1: decorations.add(new dBushLeaves((zfix)fx, (zfix)fy, dBUSHLEAVES, 0, 0)); break;
5379 case 2: decorations.add(new dFlowerClippings((zfix)fx, (zfix)fy, dFLOWERCLIPPINGS, 0, 0)); break;
5380 case 3: decorations.add(new dGrassClippings((zfix)fx, (zfix)fy, dGRASSCLIPPINGS, 0, 0)); break;
5381 }
5382 }
5383 }
5384
5385 38240 void HeroClass::check_wand_block(int32_t bx, int32_t by)
5386 {
5387 //keep things inside the screen boundaries
5388 38240 bx=vbound(bx, 0, world_w-1);
5389 38240 by=vbound(by, 0, world_h-1);
5390 38240 int32_t fx=bx;
5391 38240 int32_t fy=by;
5392
5393 //first things first
5394
2/4
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
38240 if(z>8||fakez>8) return;
5395
5396 //find out which combo row/column the coordinates are in
5397 38240 bx = TRUNCATE_TILE(bx);
5398 38240 by = TRUNCATE_TILE(by);
5399
5400 38240 int32_t flag = MAPFLAG(bx,by);
5401 38240 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5402 38240 int32_t flag3=0;
5403 38240 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5404 38240 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5405 38240 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5406 38240 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5407
5408
4/8
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38240 times.
38240 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5409 flag3=mfWAND;
5410
5411
4/8
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 38240 times.
38240 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5412 flag3=mfSTRIKE;
5413
5414
7/12
✓ Branch 0 taken 38240 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38240 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38240 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 38239 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 38239 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 38239 times.
✗ Branch 11 not taken.
38240 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5415 38239 return;
5416
5417
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if((trigger_secrets_if_flag(bx,by,mfWAND,true)==false)&&(trigger_secrets_if_flag(bx,by,mfSTRIKE,true)==false))
5418 {
5419 if(flag3==mfWAND||flag3==mfSTRIKE)
5420 {
5421 trigger_secrets_if_flag(fx,fy,mfWAND,true);
5422 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
5423 }
5424 }
5425 38240 }
5426
5427 5124 void HeroClass::check_pound_block(int bx, int by, weapon* w)
5428 {
5429
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5124 if(w && w->no_triggers()) return;
5430
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5124 if(w && w->id == wHammer && getHammerState() < 3)
5431 return;
5432
1/2
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
5124 if(get_qr(qr_POUNDLAYERS1AND2))
5433 {
5434 check_pound_block_layer(bx,by,1,w);
5435 check_pound_block_layer(bx,by,2,w);
5436 }
5437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5124 times.
5124 auto* grid = w ? w->wscreengrid : screengrid;
5438 //keep things inside the screen boundaries
5439 5124 bx=vbound(bx, 0, world_w-1);
5440 5124 by=vbound(by, 0, world_h-1);
5441 5124 int32_t fx=bx;
5442 5124 int32_t fy=by;
5443
5444 //first things first
5445
2/4
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5124 times.
5124 if(z>8||fakez>8) return;
5446
5447 //find out which combo row/column the coordinates are in
5448 5124 bx = TRUNCATE_TILE(bx);
5449 5124 by = TRUNCATE_TILE(by);
5450
5451 5124 int32_t type = COMBOTYPE(bx,by);
5452 5124 int32_t type2 = FFCOMBOTYPE(fx,fy);
5453 5124 int32_t flag = MAPFLAG(bx,by);
5454 5124 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5455 5124 int32_t flag3 = MAPFFCOMBOFLAG(fx,fy);
5456
5457 5124 rpos_t rpos = COMBOPOS_REGION(bx, by);
5458 5124 int32_t pos = RPOS_TO_POS(rpos);
5459
1/2
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
5124 if (!is_valid_rpos(rpos))
5460 return;
5461
5462 5124 bool ignorescreen=false;
5463 5124 bool ignoreffc=false;
5464 5124 bool pound=false;
5465
5466
9/10
✓ Branch 0 taken 4440 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 4430 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 4430 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4428 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 4426 times.
5124 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5467 4426 ignorescreen = true; // Affect only FFCs
5468
5469
2/2
✓ Branch 0 taken 4668 times.
✓ Branch 1 taken 456 times.
5124 if(get_bit(grid, pos) != 0)
5470 456 ignorescreen = true;
5471
5472 5124 auto current_ffc_handle = getFFCAt(fx,fy);
5473
5474
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 5084 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
5124 if (!current_ffc_handle || current_ffc_handle->ffc->recently_hit)
5475 5084 ignoreffc = true;
5476
5477
3/6
✓ Branch 0 taken 5124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5124 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5124 times.
5124 if(type2!=cPOUND && flag3!=mfSTRIKE && flag3!=mfHAMMER)
5478 5124 ignoreffc = true;
5479
5480
3/4
✓ Branch 0 taken 4597 times.
✓ Branch 1 taken 527 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4597 times.
5124 if(ignorescreen && ignoreffc) // Nothing to do.
5481 4597 return;
5482
5483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 mapscr *s = cur_screen >= 128 ? special_warp_return_scr : get_scr_for_world_xy(bx, by);
5484
5485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!ignorescreen)
5486 {
5487
3/4
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 28 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 499 times.
527 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5488 {
5489 28 trigger_secrets_if_flag(bx,by,mfHAMMER,true);
5490 28 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5491 28 }
5492
3/4
✓ Branch 0 taken 497 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 497 times.
499 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5493 {
5494 2 trigger_secrets_if_flag(bx,by,mfHAMMER,true);
5495 2 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5496 2 }
5497
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 492 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
497 else if((flag >= 16)&&(flag <= 31))
5498 {
5499 5 s->data[pos] = s->secretcombo[(s->sflag[pos])-16+4];
5500 5 s->cset[pos] = s->secretcset[(s->sflag[pos])-16+4];
5501 5 s->sflag[pos] = s->secretflag[(s->sflag[pos])-16+4];
5502 5 }
5503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 else if(flag == mfARMOS_SECRET)
5504 {
5505 s->data[pos] = s->secretcombo[sSTAIRS];
5506 s->cset[pos] = s->secretcset[sSTAIRS];
5507 s->sflag[pos] = s->secretflag[sSTAIRS];
5508 sfx(s->secretsfx);
5509 }
5510
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
492 else if((flag2 >= 16)&&(flag2 <= 31))
5511 {
5512 s->data[pos] = s->secretcombo[(s->sflag[pos])-16+4];
5513 s->cset[pos] = s->secretcset[(s->sflag[pos])-16+4];
5514 s->sflag[pos] = s->secretflag[(s->sflag[pos])-16+4];
5515 }
5516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 492 times.
492 else if(flag2 == mfARMOS_SECRET)
5517 {
5518 s->data[pos] = s->secretcombo[sSTAIRS];
5519 s->cset[pos] = s->secretcset[sSTAIRS];
5520 s->sflag[pos] = s->secretflag[sSTAIRS];
5521 sfx(s->secretsfx);
5522 }
5523 492 else pound = true;
5524 527 }
5525
5526
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!ignoreffc)
5527 {
5528 if(flag3==mfHAMMER||flag3==mfSTRIKE)
5529 {
5530 trigger_secrets_if_flag(fx,fy,mfHAMMER,true);
5531 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
5532 }
5533 else
5534 {
5535 current_ffc_handle->increment_data();
5536 }
5537 }
5538
5539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 527 times.
527 if(!ignorescreen)
5540 {
5541
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 492 times.
527 if(pound)
5542 492 s->data[pos]+=1;
5543
5544 527 set_bit(grid,pos,1);
5545
5546 527 set_bit(screengrid,pos,1);
5547
5548
5/8
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 523 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 4 times.
527 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
5549 {
5550
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 items.add(new item((zfix)bx, (zfix)by, (zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5551 4 sfx(s->secretsfx);
5552 4 }
5553
5554
4/4
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 311 times.
527 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5555 311 sfx(QMisc.miscsfx[sfxHAMMERPOUND],pan(bx));
5556
5557 527 putcombo(scrollbuf, bx - viewport.x, by - viewport.y, s->data[pos], s->cset[pos]);
5558 527 }
5559
5560
1/2
✓ Branch 0 taken 527 times.
✗ Branch 1 not taken.
527 if(!ignoreffc)
5561 {
5562 current_ffc_handle->ffc->recently_hit = true;
5563
5564 if(type2==cPOUND && get_qr(qr_MORESOUNDS))
5565 sfx(QMisc.miscsfx[sfxHAMMERPOUND],pan(bx));
5566 }
5567
5568 527 return;
5569 5124 }
5570
5571 void HeroClass::check_pound_block_layer(int bx, int by, int lyr, weapon* w)
5572 {
5573 if(lyr < 1 || lyr > 2) return; //sanity
5574 //keep things inside the screen boundaries
5575 bx=vbound(bx, 0, world_w-1);
5576 by=vbound(by, 0, world_h-1);
5577 int32_t cid = MAPCOMBOL(lyr,bx,by);
5578 newcombo const& scr_cmb = combobuf[cid];
5579 auto* grid = w ? w->wscreengrid_layer[lyr-1] : screengrid_layer[lyr-1];
5580
5581 //first things first
5582 if(z>8||fakez>8) return;
5583
5584 //find out which combo row/column the coordinates are in
5585 bx = TRUNCATE_TILE(bx);
5586 by = TRUNCATE_TILE(by);
5587
5588 int32_t type = scr_cmb.type;
5589 int32_t flag = MAPFLAGL(lyr,bx,by);
5590 int32_t flag2 = scr_cmb.flag;
5591 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, lyr);
5592 int32_t i = rpos_handle.pos;
5593
5594 bool pound=false;
5595
5596 if(type!=cPOUND && flag!=mfHAMMER && flag!=mfSTRIKE && flag2!=mfHAMMER && flag2!=mfSTRIKE)
5597 return;
5598
5599 if(get_bit(grid, i) != 0)
5600 return;
5601
5602 mapscr *s = rpos_handle.scr;
5603
5604 if(flag==mfHAMMER||flag==mfSTRIKE) // Takes precedence over Secret Tile and Armos->Secret
5605 {
5606 trigger_secrets_if_flag(bx,by,mfHAMMER,true);
5607 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5608 }
5609 else if(flag2==mfHAMMER||flag2==mfSTRIKE)
5610 {
5611 trigger_secrets_if_flag(bx,by,mfHAMMER,true);
5612 trigger_secrets_if_flag(bx,by,mfSTRIKE,true);
5613 }
5614 else if((flag >= 16)&&(flag <= 31))
5615 {
5616 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5617 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5618 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5619 }
5620 else if(flag == mfARMOS_SECRET)
5621 {
5622 s->data[i] = s->secretcombo[sSTAIRS];
5623 s->cset[i] = s->secretcset[sSTAIRS];
5624 s->sflag[i] = s->secretflag[sSTAIRS];
5625 sfx(s->secretsfx);
5626 }
5627 else if((flag2 >= 16)&&(flag2 <= 31))
5628 {
5629 s->data[i] = s->secretcombo[(s->sflag[i])-16+4];
5630 s->cset[i] = s->secretcset[(s->sflag[i])-16+4];
5631 s->sflag[i] = s->secretflag[(s->sflag[i])-16+4];
5632 }
5633 else if(flag2 == mfARMOS_SECRET)
5634 {
5635 s->data[i] = s->secretcombo[sSTAIRS];
5636 s->cset[i] = s->secretcset[sSTAIRS];
5637 s->sflag[i] = s->secretflag[sSTAIRS];
5638 sfx(s->secretsfx);
5639 }
5640 else pound = true;
5641
5642 if(pound)
5643 s->data[i]+=1;
5644
5645 set_bit(grid,i,1);
5646
5647 if((flag==mfARMOS_ITEM||flag2==mfARMOS_ITEM) && (!getmapflag(s, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (s->flags9&fBELOWRETURN)))
5648 {
5649 items.add(new item((zfix)bx, (zfix)by, (zfix)0, s->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((s->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
5650 sfx(s->secretsfx);
5651 }
5652
5653 if(type==cPOUND && get_qr(qr_MORESOUNDS))
5654 sfx(QMisc.miscsfx[sfxHAMMERPOUND],pan(bx));
5655
5656
5657 putcombo(scrollbuf,bx-viewport.x,by-viewport.y,s->data[i],s->cset[i]);
5658 }
5659
5660 void HeroClass::check_wand_block(weapon *w)
5661 {
5662
5663 int32_t par_item = w->parentitem;
5664 int32_t usewpn = -1;
5665 if ( par_item > -1 )
5666 {
5667 usewpn = itemsbuf[par_item].weap_data.imitate_weapon;
5668 }
5669 else if ( par_item == -1 && w->ScriptGenerated )
5670 {
5671 usewpn = w->useweapon;
5672 }
5673 if(usewpn != wWand) return;
5674
5675
5676 int32_t bx = 0, by = 0;
5677 bx = ((int32_t)w->x) + (((int32_t)w->hit_width)/2);
5678 by = ((int32_t)w->y) + (((int32_t)w->hit_height)/2);
5679
5680 //keep things inside the screen boundaries
5681 bx=vbound(bx, 0, world_w-1);
5682 by=vbound(by, 0, world_h-1);
5683 int32_t fx=bx;
5684 int32_t fy=by;
5685 int32_t cid = MAPCOMBO(bx,by);
5686 //first things first
5687 if(z>8||fakez>8) return;
5688
5689 //find out which combo row/column the coordinates are in
5690 bx = TRUNCATE_TILE(bx);
5691 by = TRUNCATE_TILE(by);
5692
5693 int32_t flag = MAPFLAG(bx,by);
5694 int32_t flag2 = MAPCOMBOFLAG(bx,by);
5695 int32_t flag3=0;
5696 int32_t flag31 = MAPFFCOMBOFLAG(fx,fy);
5697 int32_t flag32 = MAPFFCOMBOFLAG(fx,fy);
5698 int32_t flag33 = MAPFFCOMBOFLAG(fx,fy);
5699 int32_t flag34 = MAPFFCOMBOFLAG(fx,fy);
5700
5701 if(flag31==mfWAND||flag32==mfWAND||flag33==mfWAND||flag34==mfWAND)
5702 flag3=mfWAND;
5703
5704 if(flag31==mfSTRIKE||flag32==mfSTRIKE||flag33==mfSTRIKE||flag34==mfSTRIKE)
5705 flag3=mfSTRIKE;
5706
5707 if(flag!=mfWAND&&flag2!=mfWAND&&flag3!=mfWAND&&flag!=mfSTRIKE&&flag2!=mfSTRIKE&&flag3!=mfSTRIKE)
5708 return;
5709
5710 if((trigger_secrets_if_flag(bx,by,mfWAND,true)==false)&&(trigger_secrets_if_flag(bx,by,mfSTRIKE,true)==false))
5711 {
5712 if(flag3==mfWAND||flag3==mfSTRIKE)
5713 {
5714 trigger_secrets_if_flag(fx,fy,mfWAND,true);
5715 trigger_secrets_if_flag(fx,fy,mfSTRIKE,true);
5716 }
5717 }
5718 }
5719
5720 //defend results should match defence types.
5721 //RETURN VALUES:
5722 // -1 iGNORE WEAPON
5723 // 0 No effects
5724 // 1 Effects, weapon is not ignored or removed
5725 11562 int32_t HeroClass::defend(weapon *w)
5726 {
5727 11562 int32_t def = conv_edef_unblockable(defence[w->id], w->unblockable);
5728
2/25
✓ Branch 0 taken 11553 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
11562 switch(def)
5729 {
5730 11553 case edNORMAL: return 1;
5731 case edHALFDAMAGE: // : IMPLEMENTED : Take half damage
5732 {
5733 w->power *= 0.5;
5734 return 1;
5735 }
5736 case edQUARTDAMAGE:
5737 {
5738 w->power *= 0.25;
5739 return 1;
5740 }
5741 case edSTUNONLY:
5742 {
5743 setStunClock(120);
5744 return 1;
5745 }
5746 case edSTUNORCHINK: // : IMPLEMENTED : If damage > 0, stun instead. Else, bounce off.
5747 {
5748 if (w->power > 0)
5749 {
5750 setStunClock(120);
5751 return 1;
5752 }
5753 else
5754 {
5755 sfx(WAV_CHINK,pan(x));
5756 w->dead = 0;
5757 return -1;
5758 }
5759 }
5760 case edSTUNORIGNORE: // : IMPLEMENTED : If damage > 0, stun instead. Else, ignore.
5761 {
5762 if (w->power > 0)
5763 {
5764 setStunClock(120);
5765 return 1;
5766 }
5767 else
5768 {
5769 return -1;
5770 }
5771 }
5772 case edCHINKL1: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5773 {
5774 if (w->power < 1)
5775 {
5776 sfx(WAV_CHINK,pan(x));
5777 w->dead = 0;
5778 return -1;
5779 }
5780 else
5781 {
5782 return 1;
5783 }
5784 }
5785 case edCHINKL2: // : IMPLEMENTED : Bounce off unless damage >= 2
5786 {
5787 if (w->power < 2)
5788 {
5789 sfx(WAV_CHINK,pan(x));
5790 w->dead = 0;
5791 return -1;
5792 }
5793 else
5794 {
5795 return 1;
5796 }
5797 }
5798 case edCHINKL4: //: IMPLEMENTED : Bounce off unless damage >= 4
5799 {
5800 if (w->power < 4)
5801 {
5802 sfx(WAV_CHINK,pan(x));
5803 w->dead = 0;
5804 return -1;
5805 }
5806 else
5807 {
5808 return 1;
5809 }
5810 }
5811 case edCHINKL6: // : IMPLEMENTED : Bounce off unless damage >= 6
5812 {
5813 if (w->power < 6)
5814 {
5815 sfx(WAV_CHINK,pan(x));
5816 w->dead = 0;
5817 return -1;
5818 }
5819 else
5820 {
5821 return 1;
5822 }
5823 }
5824 case edCHINKL8: // : IMPLEMENTED : Bounce off unless damage >= 8
5825 {
5826 if (w->power < 8)
5827 {
5828 sfx(WAV_CHINK,pan(x));
5829 w->dead = 0;
5830 return -1;
5831 }
5832 else
5833 {
5834 return 1;
5835 }
5836 }
5837 case edCHINK: // : IMPLEMENTED : Bounces off, plays SFX_CHINK
5838 {
5839 sfx(WAV_CHINK,pan(x));
5840 w->dead = 0;
5841 return -1;
5842 }
5843 case edIGNOREL1: // : IMPLEMENTED : Ignore unless damage > 1.
5844 {
5845 if (w->power < 1)
5846 {
5847 return -1;
5848 }
5849 else return 1;
5850 }
5851 case edIGNORE: // : IMPLEMENTED : Do Nothing
5852 {
5853 return -1;
5854 }
5855 case ed1HKO: // : IMPLEMENTED : One-hit knock-out
5856 {
5857 game->set_life(0);
5858 return 1;
5859 }
5860 case edCHINKL10: //: IMPLEMENTED : If damage is less than 10
5861 {
5862 if (w->power < 10)
5863 {
5864 sfx(WAV_CHINK,pan(x));
5865 w->dead = 0;
5866 return -1;
5867 }
5868 else
5869 {
5870 return 1;
5871 }
5872 }
5873 case ed2x: // : IMPLEMENTED : Double damage.
5874 {
5875 w->power *= 2;
5876 return 1;
5877 }
5878 case ed3x: // : IMPLEMENTED : Triple Damage.
5879 {
5880 w->power *= 3;
5881 return 1;
5882 }
5883 case ed4x: // : IMPLEMENTED : 4x damage.
5884 {
5885 w->power *= 4;
5886 return 1;
5887 }
5888 case edHEAL: // : IMPLEMENTED : Gain the weapon damage in HP.
5889 {
5890 //sfx(WAV_HEAL,pan(x));
5891 game->set_life(zc_min(game->get_life()+w->power, game->get_maxlife()));
5892 w->dead = 0;
5893 return -1;
5894 }
5895
5896 case edFREEZE: return 1; //Not IMPLEMENTED
5897
5898 case edLEVELDAMAGE: //Damage * item level
5899 {
5900 w->power *= w->family_level;
5901 return 1;
5902 }
5903 case edLEVELREDUCTION: //Damage / item level
5904 {
5905 if ( w->family_level > 0 )
5906 {
5907 w->power /= w->family_level;
5908 }
5909 else w->power = 0;
5910 return 1;
5911 }
5912
5913 //edLEVELCHINK2, //If item level is < 2: This needs a weapon variable that is set by
5914 //edLEVELCHINK3, //If item level is < 3: the item that generates it (itemdata::level stored to
5915 //edLEVELCHINK4, //If item level is < 4: weapon::level, or something similar; then a check to
5916 //edLEVELCHINK5, //If item level is < 5: read weapon::level in hit detection.
5917
5918 //edSHOCK, //buzz blob
5919
5920
5921 case edBREAKSHIELD: //destroy the player's present shield
5922 {
5923 w->power = 0;
5924 w->dead = 0;
5925 int32_t itemid = getCurrentShield();
5926 //sfx(WAV_BREAKSHIELD,pan(x));
5927 if(itemsbuf[itemid].flags&item_edible)
5928 game->set_item(itemid, false);
5929 //Remove Hero's shield
5930 return -1;
5931 }
5932
5933
5934
5935 9 default: return 0;
5936 }
5937 11562 }
5938 ALLEGRO_COLOR HeroClass::hitboxColor(byte opacity) const
5939 {
5940 return al_map_rgba(0,0,255,opacity);
5941 }
5942 10938 int32_t HeroClass::compareDir(int32_t other)
5943 {
5944
5/6
✓ Branch 0 taken 10921 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10921 times.
✓ Branch 4 taken 105 times.
✓ Branch 5 taken 10833 times.
10938 if(other != NORMAL_DIR(other))
5945 105 return 0; //*sigh* scripts expect dirs >=8 to NOT hit shields...
5946 10833 int32_t ret = 0;
5947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10833 times.
10833 auto d = (shield_forcedir < 0) ? dir : shield_forcedir;
5948
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2141 times.
✓ Branch 2 taken 1854 times.
✓ Branch 3 taken 3461 times.
✓ Branch 4 taken 3377 times.
10833 switch(d)
5949 {
5950 case up:
5951 {
5952
3/3
✓ Branch 0 taken 509 times.
✓ Branch 1 taken 848 times.
✓ Branch 2 taken 784 times.
2141 switch(X_DIR(other))
5953 {
5954 case left:
5955 848 ret |= CMPDIR_RIGHT;
5956 848 break;
5957 case right:
5958 784 ret |= CMPDIR_LEFT;
5959 784 break;
5960 }
5961
3/3
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 1551 times.
2141 switch(Y_DIR(other))
5962 {
5963 case up:
5964 335 ret |= CMPDIR_BACK;
5965 335 break;
5966 case down:
5967 1551 ret |= CMPDIR_FRONT;
5968 1551 break;
5969 }
5970 2141 break;
5971 }
5972 case down:
5973 {
5974
3/3
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 617 times.
✓ Branch 2 taken 709 times.
1854 switch(X_DIR(other))
5975 {
5976 case left:
5977 617 ret |= CMPDIR_LEFT;
5978 617 break;
5979 case right:
5980 709 ret |= CMPDIR_RIGHT;
5981 709 break;
5982 }
5983
3/3
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 1262 times.
✓ Branch 2 taken 317 times.
1854 switch(Y_DIR(other))
5984 {
5985 case up:
5986 1262 ret |= CMPDIR_FRONT;
5987 1262 break;
5988 case down:
5989 317 ret |= CMPDIR_BACK;
5990 317 break;
5991 }
5992 1854 break;
5993 }
5994 case left:
5995 {
5996
3/3
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 2768 times.
3461 switch(X_DIR(other))
5997 {
5998 case left:
5999 496 ret |= CMPDIR_BACK;
6000 496 break;
6001 case right:
6002 2768 ret |= CMPDIR_FRONT;
6003 2768 break;
6004 }
6005
3/3
✓ Branch 0 taken 1385 times.
✓ Branch 1 taken 891 times.
✓ Branch 2 taken 1185 times.
3461 switch(Y_DIR(other))
6006 {
6007 case up:
6008 891 ret |= CMPDIR_LEFT;
6009 891 break;
6010 case down:
6011 1185 ret |= CMPDIR_RIGHT;
6012 1185 break;
6013 }
6014 3461 break;
6015 }
6016 case right:
6017 {
6018
3/3
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 2705 times.
✓ Branch 2 taken 483 times.
3377 switch(X_DIR(other))
6019 {
6020 case left:
6021 2705 ret |= CMPDIR_FRONT;
6022 2705 break;
6023 case right:
6024 483 ret |= CMPDIR_BACK;
6025 483 break;
6026 }
6027
3/3
✓ Branch 0 taken 1337 times.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 1208 times.
3377 switch(Y_DIR(other))
6028 {
6029 case up:
6030 832 ret |= CMPDIR_RIGHT;
6031 832 break;
6032 case down:
6033 1208 ret |= CMPDIR_LEFT;
6034 1208 break;
6035 }
6036 3377 break;
6037 }
6038 }
6039 10833 return ret;
6040 10938 }
6041
6042 10938 bool compareShield(int32_t cmpdir, itemdata const& shield)
6043 {
6044
1/2
✓ Branch 0 taken 10938 times.
✗ Branch 1 not taken.
10938 bool standard = !(shield.flags&item_flag9) || usingActiveShield();
6045
1/2
✓ Branch 0 taken 10938 times.
✗ Branch 1 not taken.
10938 if(standard) //Use standard sides, either a passive shield, or a held active shield
6046 {
6047
4/4
✓ Branch 0 taken 8286 times.
✓ Branch 1 taken 2652 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 8277 times.
10938 if((cmpdir&CMPDIR_FRONT) && (shield.flags&item_flag1))
6048 8277 return true;
6049
3/4
✓ Branch 0 taken 1631 times.
✓ Branch 1 taken 1030 times.
✓ Branch 2 taken 1631 times.
✗ Branch 3 not taken.
2661 else if((cmpdir&CMPDIR_BACK) && (shield.flags&item_flag2))
6050 return true;
6051
3/4
✓ Branch 0 taken 1029 times.
✓ Branch 1 taken 1632 times.
✓ Branch 2 taken 1029 times.
✗ Branch 3 not taken.
2661 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&item_flag3))
6052 return true;
6053
3/4
✓ Branch 0 taken 1140 times.
✓ Branch 1 taken 1521 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1140 times.
2661 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&item_flag4))
6054 return true;
6055 2661 }
6056 else //Active Shield that is NOT held down
6057 {
6058 if((cmpdir&CMPDIR_FRONT) && (shield.flags&item_flag5))
6059 return true;
6060 else if((cmpdir&CMPDIR_BACK) && (shield.flags&item_flag6))
6061 return true;
6062 else if((cmpdir&CMPDIR_LEFT) && (shield.flags&item_flag7))
6063 return true;
6064 else if((cmpdir&CMPDIR_RIGHT) && (shield.flags&item_flag8))
6065 return true;
6066 }
6067 2661 return false;
6068 10938 }
6069
6070 7259 static bool sh_check(uint fl_block, uint fl_ref, int wty, bool& reflect, bool boss, bool defret)
6071 {
6072 7259 reflect = false;
6073
10/22
✓ Branch 0 taken 3555 times.
✓ Branch 1 taken 329 times.
✓ Branch 2 taken 416 times.
✓ Branch 3 taken 988 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 510 times.
✓ Branch 6 taken 1039 times.
✓ Branch 7 taken 2 times.
✓ Branch 8 taken 20 times.
✓ Branch 9 taken 391 times.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
7259 switch(wty)
6074 {
6075 case ewBrang:
6076
1/2
✓ Branch 0 taken 391 times.
✗ Branch 1 not taken.
391 if(!(fl_block & sh_brang)) break;
6077
6078 391 reflect = ((fl_ref & sh_brang) != 0);
6079 391 return true;
6080 case ewArrow:
6081 case wRefArrow:
6082
1/2
✓ Branch 0 taken 329 times.
✗ Branch 1 not taken.
329 if(!(fl_block & sh_arrow)) break;
6083
6084 329 reflect = ((fl_ref & sh_arrow) != 0);
6085 329 return true;
6086
6087 case ewRock:
6088 case wRefRock:
6089
1/2
✓ Branch 0 taken 416 times.
✗ Branch 1 not taken.
416 if(!(fl_block & sh_rock)) break;
6090
6091 416 reflect = ((fl_ref & sh_rock) != 0);
6092 416 return true;
6093 case ewFlame:
6094 case wRefFire:
6095
2/2
✓ Branch 0 taken 639 times.
✓ Branch 1 taken 349 times.
988 if(!(fl_block & sh_flame)) break;
6096
6097 639 reflect = ((fl_ref & sh_flame) != 0);
6098 639 return true;
6099 case ewFlame2:
6100 case wRefFire2:
6101 if(get_qr(qr_BROKEN_FLAME_ARROW_REFLECTING))
6102 return true;
6103 if(!(fl_block & sh_flame2)) break;
6104
6105 reflect = ((fl_ref & sh_flame2) != 0);
6106 return true;
6107
6108 case ewFireball2:
6109 case ewFireball:
6110 case wRefFireball:
6111 {
6112 3555 int32_t mask = (boss ? sh_fireball2 : sh_fireball);
6113
6114
2/2
✓ Branch 0 taken 3071 times.
✓ Branch 1 taken 484 times.
3555 if(!(fl_block & mask)) break;
6115
6116 3071 reflect = ((fl_ref & mask) != 0);
6117 3071 return true;
6118 }
6119
6120 case ewSword:
6121 case wRefBeam:
6122
2/2
✓ Branch 0 taken 419 times.
✓ Branch 1 taken 91 times.
510 if(!(fl_block & sh_sword)) break;
6123
6124 419 reflect = ((fl_ref & sh_sword) != 0);
6125 419 return true;
6126
6127 case wRefMagic:
6128 case ewMagic:
6129
2/2
✓ Branch 0 taken 969 times.
✓ Branch 1 taken 70 times.
1039 if(!(fl_block & sh_magic)) break;
6130
6131 969 reflect = ((fl_ref & sh_magic) != 0);
6132 969 return true;
6133
6134 #define SCRIPT_SHBLOCK(scrfl) \
6135 if(!(fl_block & (sh_script|scrfl))) break; \
6136 reflect = ((fl_ref & (sh_script|scrfl)) != 0); \
6137 return true
6138
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 case wScript1: SCRIPT_SHBLOCK(sh_script1);
6139 case wScript2: SCRIPT_SHBLOCK(sh_script2);
6140 case wScript3: SCRIPT_SHBLOCK(sh_script3);
6141 case wScript4: SCRIPT_SHBLOCK(sh_script4);
6142 case wScript5: SCRIPT_SHBLOCK(sh_script5);
6143 case wScript6: SCRIPT_SHBLOCK(sh_script6);
6144 case wScript7: SCRIPT_SHBLOCK(sh_script7);
6145 case wScript8: SCRIPT_SHBLOCK(sh_script8);
6146 case wScript9: SCRIPT_SHBLOCK(sh_script9);
6147 case wScript10: SCRIPT_SHBLOCK(sh_script10);
6148 #undef SCRIPT_SHBLOCK
6149
6150 case wWind:
6151 if(!(fl_block & sh_lw_wind)) break;
6152
6153 reflect = ((fl_ref & sh_lw_wind) != 0);
6154 return true;
6155 case ewWind:
6156 if(!(fl_block & sh_ew_wind)) break;
6157
6158 reflect = ((fl_ref & sh_ew_wind) != 0);
6159 return true;
6160
6161 case ewLitBomb:
6162 case ewLitSBomb:
6163 2 return true;
6164
6165 default:
6166 20 return defret;
6167 }
6168 1003 return false;
6169 7259 }
6170
6171 bool HeroClass::check_ewpn_collide(weapon* w)
6172 {
6173 if(w->ignoreHero || w->fallclk|| w->drownclk)
6174 return false;
6175 if(!w->hit(x+7,y+7-fakez,z,2,2,1))
6176 return false;
6177
6178 int32_t stompid = current_item_id(itype_stompboots);
6179
6180 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6181 ((z+fakez) > (w->z+(w->fakez))) ||
6182 ((isSideViewHero() && (y+16)-(w->y)<=14) && falling_oldy<y)))
6183 {
6184 itemdata const& stomp = itemsbuf[stompid];
6185 bool reflect = false; //unused, always false
6186 if(!sh_check(stomp.misc2, 0, w->id, reflect, w->level&1, true))
6187 {
6188 w->onhit(false);
6189 sfx(WAV_CHINK,pan(x));
6190 return false;
6191 }
6192 }
6193
6194 int32_t defresult = defend(w);
6195 if ( defresult == -1 ) return false; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6196
6197 if(w->id==ewWind)
6198 {
6199 xofs=1000;
6200 action=freeze; FFCore.setHeroAction(freeze);
6201 w->misc=999; // in enemy wind
6202 attackclk=0;
6203 return false;
6204 }
6205
6206 switch(w->id)
6207 {
6208 case ewLitBomb:
6209 case ewBomb:
6210 case ewLitSBomb:
6211 case ewSBomb:
6212 return true;
6213 }
6214
6215 int32_t itemid = getCurrentShield(false);
6216 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6217 return true;
6218 itemdata const& shield = itemsbuf[itemid];
6219 bool allow_inactive = (shield.flags & item_flag9);
6220 auto cmpdir = compareDir(w->dir);
6221 bool hitshield = compareShield(cmpdir, shield);
6222
6223 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6224 return true;
6225
6226 if(!hitshield)
6227 return true;
6228
6229 paymagiccost(itemid);
6230
6231 bool reflect = false;
6232
6233 if(!sh_check(shield.misc1, shield.misc2, w->id, reflect, w->level&1, true))
6234 return true;
6235
6236 if(reflect && (w->unblockable&WPNUNB_REFL))
6237 reflect = false;
6238 if(!reflect && (w->unblockable&WPNUNB_SHLD))
6239 return true;
6240
6241 int32_t oldid = w->id;
6242 w->onhit(false, reflect ? 2 : 1, dir);
6243
6244 sfx(shield.usesound,pan(x));
6245 return true;
6246 }
6247
6248 12942228 int32_t HeroClass::EwpnHit()
6249 {
6250
2/2
✓ Branch 0 taken 12936777 times.
✓ Branch 1 taken 7523644 times.
20460421 for(int32_t i=0; i<Ewpns.Count(); i++)
6251 {
6252
2/2
✓ Branch 0 taken 7512082 times.
✓ Branch 1 taken 11562 times.
7523644 if(Ewpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6253 {
6254 11562 weapon *ew = (weapon*)(Ewpns.spr(i));
6255
6256
3/6
✓ Branch 0 taken 11562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11562 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11562 times.
11562 if((ew->ignoreHero)==true || ew->fallclk|| ew->drownclk)
6257 break;
6258
6259 11562 int32_t stompid = current_item_id(itype_stompboots);
6260
6261
5/10
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 11552 times.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11562 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
6262
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 ((z+fakez) > (ew->z+(ew->fakez))) ||
6263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 ((isSideViewHero() && (y+16)-(ew->y)<=14) && falling_oldy<y)))
6264 {
6265 itemdata const& stomp = itemsbuf[stompid];
6266 bool reflect = false; //unused, always false
6267 if(!sh_check(stomp.misc2, 0, ew->id, reflect, ew->level&1, true))
6268 {
6269 ew->onhit(false);
6270 sfx(WAV_CHINK,pan(x));
6271 continue;
6272 }
6273 }
6274
6275 11562 int32_t defresult = defend(ew);
6276
1/2
✓ Branch 0 taken 11562 times.
✗ Branch 1 not taken.
11562 if ( defresult == -1 ) return -1; //The weapon did something special, but it is otherwise ignored, possibly killed by defend().
6277
6278
2/2
✓ Branch 0 taken 11559 times.
✓ Branch 1 taken 3 times.
11562 if(ew->id==ewWind)
6279 {
6280 3 xofs=1000;
6281 3 action=freeze; FFCore.setHeroAction(freeze);
6282 3 ew->misc=999; // in enemy wind
6283 3 attackclk=0;
6284 3 return -1;
6285 }
6286
6287
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 11468 times.
11559 switch(ew->id)
6288 {
6289 case ewLitBomb:
6290 case ewBomb:
6291 case ewLitSBomb:
6292 case ewSBomb:
6293 91 return i;
6294 }
6295
6296 11468 int32_t itemid = getCurrentShield(false);
6297
4/6
✓ Branch 0 taken 10926 times.
✓ Branch 1 taken 542 times.
✓ Branch 2 taken 10926 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10926 times.
11468 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6298 542 return i;
6299 10926 itemdata const& shield = itemsbuf[itemid];
6300 10926 bool allow_inactive = (shield.flags & item_flag9);
6301 10926 auto cmpdir = compareDir(ew->dir);
6302 10926 bool hitshield = compareShield(cmpdir, shield);
6303
6304
12/20
✓ Branch 0 taken 10926 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10926 times.
✓ Branch 4 taken 8816 times.
✓ Branch 5 taken 2110 times.
✓ Branch 6 taken 8816 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8754 times.
✓ Branch 9 taken 62 times.
✓ Branch 10 taken 8754 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8754 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 8754 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 8754 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 8754 times.
✗ Branch 19 not taken.
10926 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6305 2172 return i;
6306
6307
2/2
✓ Branch 0 taken 6765 times.
✓ Branch 1 taken 1989 times.
8754 if(!hitshield)
6308 1989 return i;
6309
6310 6765 paymagiccost(itemid);
6311
6312 6765 bool reflect = false;
6313
6314
2/2
✓ Branch 0 taken 6111 times.
✓ Branch 1 taken 654 times.
6765 if(!sh_check(shield.misc1, shield.misc2, ew->id, reflect, ew->level&1, true))
6315 654 return i;
6316
6317
3/4
✓ Branch 0 taken 1609 times.
✓ Branch 1 taken 4502 times.
✓ Branch 2 taken 1609 times.
✗ Branch 3 not taken.
6111 if(reflect && (ew->unblockable&WPNUNB_REFL))
6318 reflect = false;
6319
3/4
✓ Branch 0 taken 4502 times.
✓ Branch 1 taken 1609 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4502 times.
6111 if(!reflect && (ew->unblockable&WPNUNB_SHLD))
6320 return i;
6321
6322 6111 int32_t oldid = ew->id;
6323 6111 ew->onhit(false, reflect ? 2 : 1, dir);
6324
6325 6111 sfx(shield.usesound,pan(x));
6326 6111 }
6327 7518193 }
6328
6329 12936777 return -1;
6330 12942228 }
6331
6332 12942238 int32_t HeroClass::LwpnHit() //only here to check magic hits
6333 {
6334
2/2
✓ Branch 0 taken 12771544 times.
✓ Branch 1 taken 4298431 times.
17069975 for(int32_t i=0; i<Lwpns.Count(); i++)
6335
2/2
✓ Branch 0 taken 4127731 times.
✓ Branch 1 taken 170700 times.
4298437 if(Lwpns.spr(i)->hit(x+7,y+7-fakez,z,2,2,1))
6336 {
6337 170700 weapon *lw = (weapon*)(Lwpns.spr(i));
6338
6339
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 170684 times.
170700 if((lw->ignoreHero)==true)
6340 170684 break;
6341
6342
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 switch(lw->id)
6343 {
6344 case wRefFireball: case wRefMagic: case wRefBeam:
6345 case wRefRock: case wRefArrow: case wRefFire:
6346 case wRefFire2:
6347 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
6348 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
6349 16 break;
6350 default:
6351 return -1;
6352 }
6353 16 int32_t itemid = getCurrentShield(false);
6354
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
16 if(itemid<0 || !(checkbunny(itemid) && checkmagiccost(itemid)))
6355 4 return i;
6356 12 itemdata const& shield = itemsbuf[itemid];
6357 12 auto cmpdir = compareDir(lw->dir);
6358 12 bool hitshield = compareShield(cmpdir, shield);
6359 12 bool reflect = false;
6360
6361
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(!hitshield)
6362 6 return i;
6363
6364 6 bool allow_inactive = (shield.flags & item_flag9);
6365
10/20
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 6 times.
✗ Branch 19 not taken.
6 if(!allow_inactive && ((lift_wpn && (liftflags & LIFTFL_DIS_SHIELD)) || (action==attacking||action==sideswimattacking) || action==swimming || action == sideswimming || action == sideswimattacking || charging > 0 || spins > 0 || hopclk==0xFF))
6366 return i;
6367
6368
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!sh_check(shield.misc1, shield.misc2, lw->id, reflect, lw->level&1, true))
6369 return i;
6370
6371 6 paymagiccost(itemid);
6372
6373 6 lw->onhit(false, reflect ? 2 : 1, dir);
6374 6 sfx(shield.usesound,pan(x));
6375 6 }
6376
6377 12942228 return -1;
6378 12942238 }
6379
6380 105 bool HeroClass::try_lwpn_hit(weapon* w)
6381 {
6382 105 int32_t itemid = w->parentitem;
6383 105 int indx = Lwpns.find(w);
6384 //if ( itemdbuf[parentitem].flags&item_flags3 ) //can damage Hero
6385 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6386
7/12
✗ Branch 0 not taken.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 70 times.
✓ Branch 4 taken 35 times.
✓ Branch 5 taken 35 times.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 35 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
105 if((!(itemid==-1&&get_qr(qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].type==itype_candle||itemsbuf[itemid].type==itype_book)&&(itemsbuf[itemid].flags & item_flag3)))) && scriptcoldet && !fallclk && (!superman || !get_qr(qr_FIREPROOFHERO2)))
6387 {
6388
2/14
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 35 times.
35 if(w->id==wFire && (superman ? ((diagonalMovement||NO_GRIDLOCK)?w->hit(x+4,y+4-fakez,z,7,7,1):w->hit(x+7,y+7-fakez,z,2,2,1)) : w->hit(this))&&
6389 (itemid < 0 || itemsbuf[itemid].type!=itype_divinefire))
6390 {
6391 std::vector<int32_t> &ev = FFCore.eventData;
6392 ev.clear();
6393 ev.push_back(lwpn_dp(indx)*10000);
6394 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6395 ev.push_back(0);
6396 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6397 ev.push_back(48*10000);
6398 ev.push_back(ZSD_LWPN*10000);
6399 ev.push_back(w->getUID());
6400 ev.push_back(ZSD_NONE*10000);
6401 ev.push_back(0);
6402
6403 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6404 int32_t dmg = ev[0]/10000;
6405 bool nullhit = ev[2] != 0;
6406
6407 if(nullhit) {ev.clear(); return true;}
6408
6409 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6410 ev[0] = ringpower(dmg)*10000;
6411
6412 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6413 dmg = ev[0]/10000;
6414 int32_t hdir = ev[1]/10000;
6415 nullhit = ev[2] != 0;
6416 bool divineprot = ev[3] != 0;
6417 int32_t iframes = ev[4] / 10000;
6418 ev.clear();
6419 if(nullhit) return true;
6420 if (Lwpns.spr(indx) != w)
6421 {
6422 auto hit = Lwpns.find(w);
6423 if (hit < 0)
6424 w = nullptr;
6425 else
6426 {
6427 w = (weapon*)Lwpns.spr(hit);
6428 indx = hit;
6429 }
6430 }
6431 if(!divineprot)
6432 {
6433 game->set_life(zc_max(game->get_life()-dmg,0));
6434 if (!get_qr(qr_BROKENHITBY) && w)
6435 {
6436 sethitHeroUID(HIT_BY_LWEAPON,(indx+1));
6437 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6438 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6439 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6440 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6441 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6442 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].type);
6443 }
6444 }
6445
6446 doHit(hdir, iframes);
6447 return true;
6448 }
6449 35 }
6450
6451 // check enemy weapons true, 1, -1
6452 //
6453
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if((itemsbuf[itemid].flags & item_flag6))
6454 {
6455 if(w->id==wBrang || (w->id==wHookshot&&!pull_hero))
6456 {
6457 int32_t itemid = w->parentitem>-1 ? w->parentitem :
6458 directWpn>-1 ? directWpn : current_item_id(w->id==wHookshot ? (w->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6459 itemid = vbound(itemid, 0, MAXITEMS-1);
6460
6461 for(int32_t j=0; j<Ewpns.Count(); j++)
6462 {
6463 sprite *t = Ewpns.spr(j);
6464
6465 if(w->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6466 {
6467 bool reflect = false;
6468 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6469 if(sh_check(itemsbuf[itemid].misc3, itemsbuf[itemid].misc4, t->id, reflect, ((weapon*)t)->level&1, false))
6470 {
6471 w->dead=1;
6472 weapon *ew = ((weapon*)t);
6473 int32_t oldid = ew->id;
6474 ew->onhit(true, reflect ? 2 : 1, w->dir);
6475 }
6476
6477 break;
6478 }
6479 }
6480 }
6481 }
6482
6483
2/6
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35 if((itemsbuf[itemid].flags & item_flag2)||(itemid==-1&&get_qr(qr_OUCHBOMBS)))
6484 {
6485 if(((w->id==wBomb)||(w->id==wSBomb)) && !superman && scriptcoldet && !fallclk)
6486 {
6487 bool didhit = w->hit(this);
6488 if(didhit)
6489 {
6490 std::vector<int32_t> &ev = FFCore.eventData;
6491 ev.clear();
6492 ev.push_back(((w->parentitem>-1 ? itemsbuf[w->parentitem].misc3 : w->power) *game->get_hp_per_heart())*10000);
6493 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6494 ev.push_back(0);
6495 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6496 ev.push_back(48*10000);
6497 ev.push_back(ZSD_LWPN*10000);
6498 ev.push_back(w->getUID());
6499 ev.push_back(ZSD_NONE*10000);
6500 ev.push_back(0);
6501
6502 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6503 int32_t dmg = ev[0]/10000;
6504 bool nullhit = ev[2] != 0;
6505
6506 if(nullhit) {ev.clear(); return true;}
6507
6508 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6509 ev[0] = ringpower(dmg)*10000;
6510
6511 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6512 dmg = ev[0]/10000;
6513 int32_t hdir = ev[1]/10000;
6514 nullhit = ev[2] != 0;
6515 bool divineprot = ev[3] != 0;
6516 int32_t iframes = ev[4] / 10000;
6517 ev.clear();
6518 if(nullhit) return true;
6519 if (Lwpns.spr(indx) != w)
6520 {
6521 auto hit = Lwpns.find(w);
6522 if (hit < 0)
6523 w = nullptr;
6524 else
6525 {
6526 w = (weapon*)Lwpns.spr(hit);
6527 indx = hit;
6528 }
6529 }
6530 if(!divineprot)
6531 {
6532 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6533 if (!get_qr(qr_BROKENHITBY) && w)
6534 {
6535 sethitHeroUID(HIT_BY_LWEAPON,(indx+1));
6536 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6537 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6538 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6539 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6540 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6541 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].type);
6542 }
6543 }
6544
6545 doHit(hdir, iframes);
6546 return true;
6547 }
6548 }
6549 }
6550
6551
4/8
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 35 times.
35 if(hclk==0 && w->id==wWind && w->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6552 {
6553 std::vector<int32_t> &ev = FFCore.eventData;
6554 ev.clear();
6555 ev.push_back(0);
6556 ev.push_back(w->dir*10000);
6557 ev.push_back(0);
6558 ev.push_back(0);
6559 ev.push_back(ZSD_LWPN*10000);
6560 ev.push_back(w->getUID());
6561 ev.push_back(ZSD_NONE*10000);
6562 ev.push_back(0);
6563
6564 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6565 bool nullhit = ev[2] != 0;
6566 if(nullhit) {ev.clear(); return true;}
6567
6568 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6569 int32_t hdir = ev[1]/10000;
6570 nullhit = ev[2] != 0;
6571 ev.clear();
6572 if(nullhit) return true;
6573 if (Lwpns.spr(indx) != w)
6574 {
6575 auto hit = Lwpns.find(w);
6576 if (hit < 0)
6577 w = nullptr;
6578 else
6579 {
6580 w = (weapon*)Lwpns.spr(hit);
6581 indx = hit;
6582 }
6583 }
6584
6585 reset_hookshot();
6586 xofs=1000;
6587 action=inwind; FFCore.setHeroAction(inwind);
6588 dir = hdir;
6589 if(w) w->dir = hdir;
6590 spins = charging = attackclk = 0;
6591
6592 // In case Hero used two whistles in a row, summoning two whirlwinds,
6593 // check which whistle's whirlwind picked him up so the correct
6594 // warp ring will be used
6595 int32_t whistle = w ? w->parentitem : -1;
6596
6597 if(whistle>-1 && itemsbuf[whistle].type==itype_whistle)
6598 whistleitem=whistle;
6599
6600 return true;
6601 }
6602 35 return false;
6603 35 }
6604
6605 bool HeroClass::try_ewpn_hit(weapon* w, bool force)
6606 {
6607 if(!force)
6608 {
6609 if(!check_ewpn_collide(w))
6610 return false;
6611 if(w->ignoreHero || w->fallclk|| w->drownclk)
6612 return false;
6613 }
6614 auto indx = Ewpns.find(w);
6615 std::vector<int32_t> &ev = FFCore.eventData;
6616 ev.clear();
6617 ev.push_back((ewpn_dp(indx)*10000));
6618 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6619 ev.push_back(0);
6620 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6621 ev.push_back(48*10000);
6622 ev.push_back(ZSD_EWPN*10000);
6623 ev.push_back(w->getUID());
6624 ev.push_back(ZSD_NONE*10000);
6625 ev.push_back(0);
6626
6627 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6628 int32_t dmg = ev[0]/10000;
6629 bool nullhit = ev[2] != 0;
6630
6631 if(nullhit) {ev.clear(); return false;}
6632
6633 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6634 ev[0] = ringpower(dmg)*10000;
6635
6636 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6637 dmg = ev[0]/10000;
6638 int32_t hdir = ev[1]/10000;
6639 nullhit = ev[2] != 0;
6640 bool divineprot = ev[3] != 0;
6641 int32_t iframes = ev[4] / 10000;
6642 ev.clear();
6643 if (nullhit) return false;
6644 if (Ewpns.spr(indx) != w)
6645 {
6646 indx = Ewpns.find(w);
6647 if (indx < 0)
6648 w = nullptr;
6649 else w = (weapon*)Ewpns.spr(indx);
6650 }
6651 if (!divineprot)
6652 {
6653 game->set_life(zc_max(game->get_life() - dmg, 0));
6654 if (w)
6655 {
6656 sethitHeroUID(HIT_BY_EWEAPON, (indx + 1));
6657 sethitHeroUID(HIT_BY_EWEAPON_UID, w->getUID());
6658 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID, w->getUID());
6659 sethitHeroUID(HIT_BY_EWEAPON_TYPE, w->id);
6660 }
6661 }
6662
6663 if(w)
6664 w->hit_pierce();
6665
6666 doHit(hdir, iframes);
6667 return true;
6668 }
6669
6670 20704094 void HeroClass::checkhit()
6671 {
6672
2/2
✓ Branch 0 taken 19992950 times.
✓ Branch 1 taken 711144 times.
20704094 if(hclk>0)
6673 {
6674 711144 --hclk;
6675 711144 }
6676
6677
1/2
✓ Branch 0 taken 20704094 times.
✗ Branch 1 not taken.
20704094 if(DivineProtectionShieldClk>0)
6678 {
6679 --DivineProtectionShieldClk;
6680
6681 if(DivineProtectionShieldClk == 0 && div_prot_item != -1)
6682 {
6683 stop_sfx(itemsbuf[div_prot_item].usesound);
6684 stop_sfx(itemsbuf[div_prot_item].usesound+1);
6685 div_prot_item = -1;
6686 }
6687 else if(get_qr(qr_MORESOUNDS) && !(DivineProtectionShieldClk&0xF00) && div_prot_item != -1)
6688 {
6689 stop_sfx(itemsbuf[div_prot_item].usesound);
6690 cont_sfx(itemsbuf[div_prot_item].usesound+1);
6691 }
6692 }
6693
6694
4/4
✓ Branch 0 taken 14173410 times.
✓ Branch 1 taken 6530684 times.
✓ Branch 2 taken 14165591 times.
✓ Branch 3 taken 7819 times.
20704094 if(hclk<39 && action==gothit)
6695 {
6696 7819 action=none; FFCore.setHeroAction(none);
6697 7819 }
6698
6699
5/6
✓ Branch 0 taken 14173410 times.
✓ Branch 1 taken 6530684 times.
✓ Branch 2 taken 14173285 times.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14173285 times.
20704094 if(hclk<39 && (action==swimhit || action == sideswimhit))
6700 {
6701 125 SetSwim();
6702 125 }
6703
6704
4/4
✓ Branch 0 taken 120977 times.
✓ Branch 1 taken 20583117 times.
✓ Branch 2 taken 34689 times.
✓ Branch 3 taken 86288 times.
20704094 if(hclk>=40 && action==gothit)
6705 {
6706 86288 int val = check_pitslide();
6707
4/4
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 85860 times.
✓ Branch 2 taken 86464 times.
✓ Branch 3 taken 86036 times.
86288 if(((ladderx+laddery) && ((hitdir&2)==ladderdir))||(!(ladderx+laddery)))
6708 {
6709
2/2
✓ Branch 0 taken 345856 times.
✓ Branch 1 taken 86464 times.
432320 for(int32_t i=0; i<4; i++)
6710 {
6711
5/5
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 73660 times.
✓ Branch 2 taken 83280 times.
✓ Branch 3 taken 90472 times.
✓ Branch 4 taken 94028 times.
345856 switch(hitdir)
6712 {
6713 case up:
6714
6/6
✓ Branch 0 taken 5371 times.
✓ Branch 1 taken 68289 times.
✓ Branch 2 taken 11653 times.
✓ Branch 3 taken 56636 times.
✓ Branch 4 taken 5513 times.
✓ Branch 5 taken 68147 times.
73660 if(hit_walkflag(x,y+(bigHitbox?-1:7),2)||(x.getInt()&7?hit_walkflag(x+16,y+(bigHitbox?-1:7),1):0))
6715 {
6716 5513 action=none; FFCore.setHeroAction(none);
6717 5513 }
6718
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 68123 times.
68147 else if (val == -1) --y;
6719
6720 73660 break;
6721
6722 case down:
6723
6/6
✓ Branch 0 taken 6907 times.
✓ Branch 1 taken 76373 times.
✓ Branch 2 taken 63185 times.
✓ Branch 3 taken 13188 times.
✓ Branch 4 taken 7065 times.
✓ Branch 5 taken 76215 times.
83280 if(hit_walkflag(x,y+16,2)||(x.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6724 {
6725 7065 action=none; FFCore.setHeroAction(none);
6726 7065 }
6727
1/2
✓ Branch 0 taken 76215 times.
✗ Branch 1 not taken.
76215 else if (val == -1) ++y;
6728
6729 83280 break;
6730
6731 case left:
6732
7/8
✓ Branch 0 taken 87097 times.
✓ Branch 1 taken 3375 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 87097 times.
✓ Branch 4 taken 10920 times.
✓ Branch 5 taken 76177 times.
✓ Branch 6 taken 3542 times.
✓ Branch 7 taken 86930 times.
90472 if(hit_walkflag(x-1,y+(bigHitbox?0:8),1)||hit_walkflag(x-1,y+8,1)||(y.getInt()&7?hit_walkflag(x-1,y+16,1):0))
6733 {
6734 3542 action=none; FFCore.setHeroAction(none);
6735 3542 }
6736
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 86894 times.
86930 else if (val == -1) --x;
6737
6738 90472 break;
6739
6740 case right:
6741
8/8
✓ Branch 0 taken 89968 times.
✓ Branch 1 taken 4060 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 89964 times.
✓ Branch 4 taken 9850 times.
✓ Branch 5 taken 80114 times.
✓ Branch 6 taken 4169 times.
✓ Branch 7 taken 89859 times.
94028 if(hit_walkflag(x+16,y+(bigHitbox?0:8),1)||hit_walkflag(x+16,y+8,1)||(y.getInt()&7?hit_walkflag(x+16,y+16,1):0))
6742 {
6743 4169 action=none; FFCore.setHeroAction(none);
6744 4169 }
6745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89859 times.
89859 else if (val == -1) ++x;
6746
6747 94028 break;
6748 }
6749 345856 }
6750 86464 }
6751 86640 }
6752
6753
20/22
✓ Branch 0 taken 13612698 times.
✓ Branch 1 taken 7091748 times.
✓ Branch 2 taken 13611749 times.
✓ Branch 3 taken 949 times.
✓ Branch 4 taken 13611749 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13593395 times.
✓ Branch 7 taken 18354 times.
✓ Branch 8 taken 13588762 times.
✓ Branch 9 taken 4633 times.
✓ Branch 10 taken 13588563 times.
✓ Branch 11 taken 199 times.
✓ Branch 12 taken 13588563 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13587657 times.
✓ Branch 15 taken 906 times.
✓ Branch 16 taken 13577526 times.
✓ Branch 17 taken 10131 times.
✓ Branch 18 taken 11373 times.
✓ Branch 19 taken 13566153 times.
✓ Branch 20 taken 7799675 times.
✓ Branch 21 taken 7811048 times.
20704446 if(hclk>0 || inlikelike == 1 || is_autowalking() || action==inwind || action==drowning || action==lavadrowning || action==sidedrowning || inwallm || isDiving() || (action==hopping && hopclk<255))
6754 {
6755 14926595 return;
6756 }
6757
6758
2/2
✓ Branch 0 taken 12519938 times.
✓ Branch 1 taken 13566115 times.
26086053 for(int32_t i=0; i<Lwpns.Count(); i++)
6759 {
6760 12519938 sprite *s = Lwpns.spr(i);
6761 12519938 int32_t itemid = ((weapon*)(Lwpns.spr(i)))->parentitem;
6762 //if ( itemdbuf[parentitem].flags&item_flags3 ) //can damage Hero
6763 //if ( itemsbuf[parentitem].misc1 > 0 ) //damages Hero by this amount.
6764
12/12
✓ Branch 0 taken 759221 times.
✓ Branch 1 taken 11760717 times.
✓ Branch 2 taken 3949825 times.
✓ Branch 3 taken 7810892 times.
✓ Branch 4 taken 3905017 times.
✓ Branch 5 taken 3905875 times.
✓ Branch 6 taken 3905771 times.
✓ Branch 7 taken 104 times.
✓ Branch 8 taken 91196 times.
✓ Branch 9 taken 3814575 times.
✓ Branch 10 taken 38783 times.
✓ Branch 11 taken 52413 times.
12519938 if((!(itemid==-1&&get_qr(qr_FIREPROOFHERO)||((itemid>-1&&itemsbuf[itemid].type==itype_candle||itemsbuf[itemid].type==itype_book)&&(itemsbuf[itemid].flags & item_flag3)))) && scriptcoldet && !fallclk && (!superman || !get_qr(qr_FIREPROOFHERO2)))
6765 {
6766
11/14
✓ Branch 0 taken 3743510 times.
✓ Branch 1 taken 123478 times.
✓ Branch 2 taken 443 times.
✓ Branch 3 taken 123035 times.
✓ Branch 4 taken 443 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 443 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 443 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3711 times.
✓ Branch 11 taken 119324 times.
✓ Branch 12 taken 3866097 times.
✓ Branch 13 taken 33 times.
3870284 if(s->id==wFire && (superman ? ((diagonalMovement||NO_GRIDLOCK)?s->hit(x+4,y+4-fakez,z,7,7,1):s->hit(x+7,y+7-fakez,z,2,2,1)) : s->hit(this))&&
6767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3296 times.
4154 (itemid < 0 || itemsbuf[itemid].type!=itype_divinefire))
6768 {
6769 33 std::vector<int32_t> &ev = FFCore.eventData;
6770 33 ev.clear();
6771 33 ev.push_back(lwpn_dp(i)*10000);
6772 33 ev.push_back(s->hitdir(x,y,16,16,dir)*10000);
6773 33 ev.push_back(0);
6774 33 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6775 33 ev.push_back(48*10000);
6776 33 ev.push_back(ZSD_LWPN*10000);
6777 33 ev.push_back(s->getUID());
6778 33 ev.push_back(ZSD_NONE*10000);
6779 33 ev.push_back(0);
6780
6781 33 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6782 33 int32_t dmg = ev[0]/10000;
6783 33 bool nullhit = ev[2] != 0;
6784
6785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(nullhit) {ev.clear(); return;}
6786
6787 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6788 33 ev[0] = ringpower(dmg)*10000;
6789
6790 33 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6791 33 dmg = ev[0]/10000;
6792 33 int32_t hdir = ev[1]/10000;
6793 33 nullhit = ev[2] != 0;
6794 33 bool divineprot = ev[3] != 0;
6795 33 int32_t iframes = ev[4] / 10000;
6796 33 ev.clear();
6797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(nullhit) return;
6798
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if (Lwpns.spr(i) != s)
6799 {
6800 auto hit = Lwpns.find(s);
6801 if (hit < 0)
6802 s = nullptr;
6803 else
6804 {
6805 s = Lwpns.spr(hit);
6806 i = hit;
6807 }
6808 }
6809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!divineprot)
6810 {
6811
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 game->set_life(zc_max(game->get_life()-dmg,0));
6812 33 weapon* w = (weapon*)s;
6813
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
33 if (!get_qr(qr_BROKENHITBY) && w)
6814 {
6815 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6816 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6817 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6818 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6819 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6820 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6821 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].type);
6822 }
6823 33 }
6824
6825 33 doHit(hdir, iframes);
6826 33 return;
6827 }
6828 3866097 }
6829
6830 // check enemy weapons true, 1, -1
6831 //
6832
2/2
✓ Branch 0 taken 494073 times.
✓ Branch 1 taken 4214940 times.
4709013 if((itemsbuf[itemid].flags & item_flag6))
6833 {
6834
6/6
✓ Branch 0 taken 380644 times.
✓ Branch 1 taken 113429 times.
✓ Branch 2 taken 34343 times.
✓ Branch 3 taken 346301 times.
✓ Branch 4 taken 7231 times.
✓ Branch 5 taken 27112 times.
494073 if(s->id==wBrang || (s->id==wHookshot&&!pull_hero))
6835 {
6836
1/2
✓ Branch 0 taken 140541 times.
✗ Branch 1 not taken.
140541 int32_t itemid = ((weapon*)s)->parentitem>-1 ? ((weapon*)s)->parentitem :
6837 directWpn>-1 ? directWpn : current_item_id(s->id==wHookshot ? (((weapon*)s)->family_class == itype_switchhook ? itype_switchhook : itype_hookshot) : itype_brang);
6838 140541 itemid = vbound(itemid, 0, MAXITEMS-1);
6839
6840
2/2
✓ Branch 0 taken 140053 times.
✓ Branch 1 taken 66159 times.
206212 for(int32_t j=0; j<Ewpns.Count(); j++)
6841 {
6842 66159 sprite *t = Ewpns.spr(j);
6843
6844
2/2
✓ Branch 0 taken 65671 times.
✓ Branch 1 taken 488 times.
66159 if(s->hit(t->x+7,t->y+7-t->fakez,t->z,2,2,1))
6845 {
6846 488 bool reflect = false;
6847 // sethitHeroUID(HIT_BY_EWEAPON,j); //set that Hero was hit by a specific eweapon index.
6848
6849
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 119 times.
488 if(sh_check(itemsbuf[itemid].misc3, itemsbuf[itemid].misc4, t->id, reflect, ((weapon*)t)->level&1, false))
6850 {
6851 119 ((weapon*)s)->dead=1;
6852 119 weapon *ew = ((weapon*)t);
6853 119 int32_t oldid = ew->id;
6854 119 ew->onhit(true, reflect ? 2 : 1, s->dir);
6855 119 }
6856 488 break;
6857 }
6858 65671 }
6859 140541 }
6860 494073 }
6861
6862
6/6
✓ Branch 0 taken 3064340 times.
✓ Branch 1 taken 1644673 times.
✓ Branch 2 taken 759221 times.
✓ Branch 3 taken 2305119 times.
✓ Branch 4 taken 106519 times.
✓ Branch 5 taken 652702 times.
4709013 if((itemsbuf[itemid].flags & item_flag2)||(itemid==-1&&get_qr(qr_OUCHBOMBS)))
6863 {
6864
7/8
✓ Branch 0 taken 1705751 times.
✓ Branch 1 taken 45441 times.
✓ Branch 2 taken 45989 times.
✓ Branch 3 taken 1705203 times.
✓ Branch 4 taken 45989 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
✓ Branch 7 taken 45960 times.
1751192 if(((s->id==wBomb)||(s->id==wSBomb)) && !superman && scriptcoldet && !fallclk)
6865 {
6866 45960 weapon* w = (weapon*)s;
6867 45960 bool didhit = s->hit(this);
6868
2/2
✓ Branch 0 taken 45925 times.
✓ Branch 1 taken 35 times.
45960 if(didhit)
6869 {
6870 35 std::vector<int32_t> &ev = FFCore.eventData;
6871 35 ev.clear();
6872
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2 times.
35 ev.push_back(((w->parentitem>-1 ? itemsbuf[w->parentitem].misc3 : w->power) *game->get_hp_per_heart())*10000);
6873 35 ev.push_back(w->hitdir(x,y,16,16,dir)*10000);
6874 35 ev.push_back(0);
6875 35 ev.push_back(DivineProtectionShieldClk>0?10000:0);
6876 35 ev.push_back(48*10000);
6877 35 ev.push_back(ZSD_LWPN*10000);
6878 35 ev.push_back(w->getUID());
6879 35 ev.push_back(ZSD_NONE*10000);
6880 35 ev.push_back(0);
6881
6882 35 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6883 35 int32_t dmg = ev[0]/10000;
6884 35 bool nullhit = ev[2] != 0;
6885
6886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(nullhit) {ev.clear(); return;}
6887
6888 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
6889 35 ev[0] = ringpower(dmg)*10000;
6890
6891 35 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6892 35 dmg = ev[0]/10000;
6893 35 int32_t hdir = ev[1]/10000;
6894 35 nullhit = ev[2] != 0;
6895 35 bool divineprot = ev[3] != 0;
6896 35 int32_t iframes = ev[4] / 10000;
6897 35 ev.clear();
6898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(nullhit) return;
6899
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if (Lwpns.spr(i) != w)
6900 {
6901 auto hit = Lwpns.find(w);
6902 if (hit < 0)
6903 s = nullptr;
6904 else
6905 {
6906 s = Lwpns.spr(hit);
6907 i = hit;
6908 }
6909 w = (weapon*)s;
6910 }
6911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(!divineprot)
6912 {
6913
5/6
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 1 times.
35 game->set_life(zc_min(game->get_maxlife(), zc_max(game->get_life()-dmg,0)));
6914
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
35 if (!get_qr(qr_BROKENHITBY) && w)
6915 {
6916 1 sethitHeroUID(HIT_BY_LWEAPON,(i+1));
6917 1 sethitHeroUID(HIT_BY_LWEAPON_UID,w->getUID());
6918 1 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID,w->getUID());
6919 1 sethitHeroUID(HIT_BY_LWEAPON_TYPE, w->id);
6920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (w->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, w->parentitem);
6921 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
6922 1 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[w->parentitem].type);
6923 1 }
6924 35 }
6925
6926 35 doHit(hdir, iframes);
6927 35 return;
6928 }
6929 45925 }
6930 1751157 }
6931
6932
7/8
✓ Branch 0 taken 4708978 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10046 times.
✓ Branch 3 taken 4698932 times.
✓ Branch 4 taken 9920 times.
✓ Branch 5 taken 126 times.
✓ Branch 6 taken 4708852 times.
✓ Branch 7 taken 126 times.
4708978 if(hclk==0 && s->id==wWind && s->hit(x+7,y+7-fakez,z,2,2,1) && !fairyclk)
6933 {
6934 126 std::vector<int32_t> &ev = FFCore.eventData;
6935 126 ev.clear();
6936 126 ev.push_back(0);
6937 126 ev.push_back(s->dir*10000);
6938 126 ev.push_back(0);
6939 126 ev.push_back(0);
6940 126 ev.push_back(ZSD_LWPN*10000);
6941 126 ev.push_back(s->getUID());
6942 126 ev.push_back(ZSD_NONE*10000);
6943 126 ev.push_back(0);
6944
6945 126 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
6946 126 bool nullhit = ev[2] != 0;
6947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(nullhit) {ev.clear(); return;}
6948
6949 126 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
6950 126 int32_t hdir = ev[1]/10000;
6951 126 nullhit = ev[2] != 0;
6952 126 ev.clear();
6953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(nullhit) return;
6954
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (Lwpns.spr(i) != s)
6955 {
6956 auto hit = Lwpns.find(s);
6957 if (hit < 0)
6958 s = nullptr;
6959 else
6960 {
6961 s = Lwpns.spr(hit);
6962 i = hit;
6963 }
6964 }
6965
6966 126 reset_hookshot();
6967 126 xofs=1000;
6968 126 action=inwind; FFCore.setHeroAction(inwind);
6969 126 dir = hdir;
6970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126 times.
126 if(s) s->dir = hdir;
6971 126 spins = charging = attackclk = 0;
6972
6973 // In case Hero used two whistles in a row, summoning two whirlwinds,
6974 // check which whistle's whirlwind picked him up so the correct
6975 // warp ring will be used
6976
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 int32_t whistle=s ? ((weapon*)s)->parentitem : -1;
6977
6978
2/4
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 126 times.
126 if(whistle>-1 && itemsbuf[whistle].type==itype_whistle)
6979 126 whistleitem=whistle;
6980
6981 126 return;
6982 }
6983 4708852 }
6984
6985
6/8
✓ Branch 0 taken 13453253 times.
✓ Branch 1 taken 112862 times.
✓ Branch 2 taken 13145123 times.
✓ Branch 3 taken 308130 times.
✓ Branch 4 taken 13145123 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 13141256 times.
26707371 if(action==rafting || action==freeze || action==sideswimfreeze ||
6986
5/8
✓ Branch 0 taken 13141256 times.
✓ Branch 1 taken 3867 times.
✓ Branch 2 taken 13141256 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13141256 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13141256 times.
✗ Branch 7 not taken.
13145123 action==casting || action==sideswimcasting || action==drowning || action==lavadrowning || action==sidedrowning)
6987 424859 return;
6988
6989 13141256 int32_t hit2 = -1;
6990 13141256 do
6991 {
6992
4/6
✓ Branch 0 taken 8850935 times.
✓ Branch 1 taken 4306832 times.
✓ Branch 2 taken 8850935 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8850935 times.
13157767 hit2 = (diagonalMovement||NO_GRIDLOCK) ? GuyHitFrom(hit2+1,x+4,y+4-fakez,z,8,8,hzsz)
6993 8850935 : GuyHitFrom(hit2+1,x+7,y+7-fakez,z,2,2,hzsz);
6994
6995
2/2
✓ Branch 0 taken 13126788 times.
✓ Branch 1 taken 30979 times.
13157767 if(hit2!=-1)
6996 {
6997
2/2
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 14468 times.
30979 if (hithero(hit2) == 0) return;
6998 16511 }
6999
2/2
✓ Branch 0 taken 16511 times.
✓ Branch 1 taken 13126788 times.
13143299 } while (hit2 != -1);
7000
6/6
✓ Branch 0 taken 12955574 times.
✓ Branch 1 taken 171214 times.
✓ Branch 2 taken 12945231 times.
✓ Branch 3 taken 10343 times.
✓ Branch 4 taken 2993 times.
✓ Branch 5 taken 12942238 times.
13126788 if (superman || !scriptcoldet || fallclk) return;
7001 12942238 hit2 = LwpnHit();
7002
7003
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 12942228 times.
12942238 if(hit2!=-1)
7004 {
7005 10 weapon* lwpnspr = (weapon*)Lwpns.spr(hit2);
7006 10 std::vector<int32_t> &ev = FFCore.eventData;
7007 10 ev.clear();
7008 10 ev.push_back((lwpn_dp(hit2)*10000));
7009 10 ev.push_back(lwpnspr->hitdir(x,y,16,16,dir)*10000);
7010 10 ev.push_back(0);
7011 10 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7012 10 ev.push_back(48*10000);
7013 10 ev.push_back(ZSD_LWPN*10000);
7014 10 ev.push_back(lwpnspr->getUID());
7015 10 ev.push_back(ZSD_NONE*10000);
7016 10 ev.push_back(0);
7017
7018 10 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7019 10 int32_t dmg = ev[0]/10000;
7020 10 bool nullhit = ev[2] != 0;
7021
7022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nullhit) {ev.clear(); return;}
7023
7024 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7025 10 ev[0] = ringpower(dmg)*10000;
7026
7027 10 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7028 10 dmg = ev[0]/10000;
7029 10 int32_t hdir = ev[1]/10000;
7030 10 nullhit = ev[2] != 0;
7031 10 bool divineprot = ev[3] != 0;
7032 10 int32_t iframes = ev[4] / 10000;
7033 10 ev.clear();
7034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(nullhit) return;
7035
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (Lwpns.spr(hit2) != lwpnspr)
7036 {
7037 hit2 = Lwpns.find(lwpnspr);
7038 if (hit2 < 0)
7039 lwpnspr = nullptr;
7040 else lwpnspr = (weapon*)Lwpns.spr(hit2);
7041 }
7042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (!divineprot)
7043 {
7044
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 game->set_life(zc_max(game->get_life() - dmg, 0));
7045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (lwpnspr)
7046 {
7047 10 sethitHeroUID(HIT_BY_LWEAPON, (hit2 + 1));
7048 10 sethitHeroUID(HIT_BY_LWEAPON_UID, lwpnspr->getUID());
7049 10 sethitHeroUID(HIT_BY_LWEAPON_ENGINE_UID, lwpnspr->getUID());
7050 10 sethitHeroUID(HIT_BY_LWEAPON_TYPE, lwpnspr->id);
7051
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if (lwpnspr->parentitem > -1) sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, lwpnspr->parentitem);
7052 8 else sethitHeroUID(HIT_BY_LWEAPON_PARENT_ID, -1);
7053 10 sethitHeroUID(HIT_BY_LWEAPON_PARENT_FAMILY, itemsbuf[lwpnspr->parentitem].type);
7054 10 }
7055 10 }
7056
7057
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(lwpnspr)
7058 10 lwpnspr->hit_pierce();
7059
7060 10 doHit(hdir, iframes);
7061 10 return;
7062 }
7063
7064 //else { sethitHeroUID(HIT_BY_LWEAPON,(0)); //fails to clear
7065
7066 12942228 hit2 = EwpnHit();
7067
7068
2/2
✓ Branch 0 taken 5448 times.
✓ Branch 1 taken 12936780 times.
12942228 if(hit2!=-1)
7069 {
7070 5448 weapon* ewpnspr = (weapon*)Ewpns.spr(hit2);
7071 5448 std::vector<int32_t> &ev = FFCore.eventData;
7072 5448 ev.clear();
7073 5448 ev.push_back((ewpn_dp(hit2)*10000));
7074 5448 ev.push_back(ewpnspr->hitdir(x,y,16,16,dir)*10000);
7075 5448 ev.push_back(0);
7076 5448 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7077 5448 ev.push_back(48*10000);
7078 5448 ev.push_back(ZSD_EWPN*10000);
7079 5448 ev.push_back(ewpnspr->getUID());
7080 5448 ev.push_back(ZSD_NONE*10000);
7081 5448 ev.push_back(0);
7082
7083 5448 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7084 5448 int32_t dmg = ev[0]/10000;
7085 5448 bool nullhit = ev[2] != 0;
7086
7087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if(nullhit) {ev.clear(); return;}
7088
7089 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7090 5448 ev[0] = ringpower(dmg)*10000;
7091
7092 5448 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7093 5448 dmg = ev[0]/10000;
7094 5448 int32_t hdir = ev[1]/10000;
7095 5448 nullhit = ev[2] != 0;
7096 5448 bool divineprot = ev[3] != 0;
7097 5448 int32_t iframes = ev[4] / 10000;
7098 5448 ev.clear();
7099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if (nullhit) return;
7100
1/2
✓ Branch 0 taken 5448 times.
✗ Branch 1 not taken.
5448 if (Ewpns.spr(hit2) != ewpnspr)
7101 {
7102 hit2 = Ewpns.find(ewpnspr);
7103 if (hit2 < 0)
7104 ewpnspr = nullptr;
7105 else ewpnspr = (weapon*)Ewpns.spr(hit2);
7106 }
7107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if (!divineprot)
7108 {
7109
2/2
✓ Branch 0 taken 5402 times.
✓ Branch 1 taken 46 times.
5448 game->set_life(zc_max(game->get_life() - dmg, 0));
7110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if (ewpnspr)
7111 {
7112 5448 sethitHeroUID(HIT_BY_EWEAPON, (hit2 + 1));
7113 5448 sethitHeroUID(HIT_BY_EWEAPON_UID, ewpnspr->getUID());
7114 5448 sethitHeroUID(HIT_BY_EWEAPON_ENGINE_UID, ewpnspr->getUID());
7115 5448 sethitHeroUID(HIT_BY_EWEAPON_TYPE, ewpnspr->id);
7116 5448 }
7117 5448 }
7118
7119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5448 times.
5448 if(ewpnspr)
7120 5448 ewpnspr->hit_pierce();
7121
7122 5448 doHit(hdir, iframes);
7123 5448 return;
7124 }
7125
7126 // The rest of this method deals with damage combos, which can be jumped over.
7127
4/4
✓ Branch 0 taken 12918402 times.
✓ Branch 1 taken 18378 times.
✓ Branch 2 taken 12918655 times.
✓ Branch 3 taken 18125 times.
12936780 if((z>0 || fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) return;
7128
7129 12918655 int32_t dx1 = (int32_t)x+8-(hero_scr->csensitive);
7130 12918655 int32_t dx2 = (int32_t)x+8+(hero_scr->csensitive-1);
7131
2/2
✓ Branch 0 taken 284213 times.
✓ Branch 1 taken 12634442 times.
12918655 int32_t dy1 = (int32_t)y+(bigHitbox?8:12)-(bigHitbox?hero_scr->csensitive:(hero_scr->csensitive+1)/2);
7132
2/2
✓ Branch 0 taken 284213 times.
✓ Branch 1 taken 12634442 times.
12918655 int32_t dy2 = (int32_t)y+(bigHitbox?8:12)+(bigHitbox?hero_scr->csensitive-1:((hero_scr->csensitive+1)/2)-1);
7133
7134
2/2
✓ Branch 0 taken 24015075 times.
✓ Branch 1 taken 12918655 times.
36933730 for(int32_t i=get_qr(qr_DMGCOMBOLAYERFIX) ? 1 : -1; i>=-1; i--) // Layers 0, 1 and 2!!
7135 24015075 checkdamagecombos(dx1,dx2,dy1,dy2,i);
7136 14309408 }
7137
7138 17639 bool HeroClass::checkdamagecombos(int32_t dx, int32_t dy)
7139 {
7140 17639 return checkdamagecombos(dx,dx,dy,dy);
7141 }
7142
7143 6055 void HeroClass::doHit(int32_t hdir, int iframes)
7144 {
7145 6055 hitdir = hdir;
7146
7147
3/6
✓ Branch 0 taken 6055 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6055 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6055 times.
6055 if (action != rafting && action != freeze && action != sideswimfreeze)
7148 {
7149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6055 times.
6055 if (IsSideSwim())
7150 {
7151 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7152 }
7153
3/4
✓ Branch 0 taken 5987 times.
✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5987 times.
6055 else if (action == swimming || hopclk == 0xFF)
7154 {
7155 68 action=swimhit; FFCore.setHeroAction(swimhit);
7156 68 }
7157 else
7158 {
7159 5987 action=gothit; FFCore.setHeroAction(gothit);
7160 }
7161 6055 }
7162
7163 6055 hclk = iframes;
7164 6055 check_on_hit();
7165
7166
8/8
✓ Branch 0 taken 6022 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 6021 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 2365 times.
✓ Branch 5 taken 3656 times.
✓ Branch 6 taken 156 times.
✓ Branch 7 taken 2209 times.
6055 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7167 {
7168 3846 spins = charging = attackclk = 0;
7169 3846 attack=none;
7170 3846 tapping = false;
7171 3846 }
7172
7173 6055 sfx(getHurtSFX(),pan(x));
7174 6055 }
7175
7176 24515278 bool HeroClass::checkdamagecombos(int32_t dx1, int32_t dx2, int32_t dy1, int32_t dy2, int32_t layer, bool solid, bool do_health_check) //layer = -1, solid = false, do_health_check = true
7177 {
7178
5/6
✓ Branch 0 taken 24515018 times.
✓ Branch 1 taken 260 times.
✓ Branch 2 taken 24512827 times.
✓ Branch 3 taken 2191 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 24512827 times.
24515278 if(hclk || superman || fallclk)
7179 2451 return false;
7180
7181 24512827 int32_t hp_mod[4] = {0};
7182 int32_t cid[8];
7183 24512827 byte hasKB = 0;
7184
7185 {
7186
2/2
✓ Branch 0 taken 11416500 times.
✓ Branch 1 taken 13096327 times.
24512827 cid[0] = layer>-1?MAPCOMBO2(layer,dx1,dy1):MAPCOMBO(dx1,dy1);
7187 24512827 newcombo& cmb = combobuf[cid[0]];
7188
4/4
✓ Branch 0 taken 24512824 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24511005 times.
✓ Branch 3 taken 1819 times.
24512827 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7189 {
7190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819 times.
1819 if(cmb.usrflags&cflag1)
7191 hp_mod[0] = cmb.attributes[0] / -10000L;
7192 else
7193 1819 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1819 times.
1819 if(!(cmb.usrflags&cflag2))
7195 1819 hasKB |= 1<<0;
7196 1819 }
7197 }
7198 {
7199
2/2
✓ Branch 0 taken 11416500 times.
✓ Branch 1 taken 13096327 times.
24512827 cid[1] = layer>-1?MAPCOMBO2(layer,dx1,dy2):MAPCOMBO(dx1,dy2);
7200 24512827 newcombo& cmb = combobuf[cid[1]];
7201
4/4
✓ Branch 0 taken 24512824 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24510959 times.
✓ Branch 3 taken 1865 times.
24512827 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7202 {
7203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865 times.
1865 if(cmb.usrflags&cflag1)
7204 hp_mod[1] = cmb.attributes[0] / -10000L;
7205 else
7206 1865 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1865 times.
1865 if(!(cmb.usrflags&cflag2))
7208 1865 hasKB |= 1<<1;
7209 1865 }
7210 }
7211 {
7212
2/2
✓ Branch 0 taken 11416500 times.
✓ Branch 1 taken 13096327 times.
24512827 cid[2] = layer>-1?MAPCOMBO2(layer,dx2,dy1):MAPCOMBO(dx2,dy1);
7213 24512827 newcombo& cmb = combobuf[cid[2]];
7214
4/4
✓ Branch 0 taken 24512824 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24510998 times.
✓ Branch 3 taken 1826 times.
24512827 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7215 {
7216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
1826 if(cmb.usrflags&cflag1)
7217 hp_mod[2] = cmb.attributes[0] / -10000L;
7218 else
7219 1826 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
1826 if(!(cmb.usrflags&cflag2))
7221 1826 hasKB |= 1<<2;
7222 1826 }
7223 }
7224 {
7225
2/2
✓ Branch 0 taken 11416500 times.
✓ Branch 1 taken 13096327 times.
24512827 cid[3] = layer>-1?MAPCOMBO2(layer,dx2,dy2):MAPCOMBO(dx2,dy2);
7226 24512827 newcombo& cmb = combobuf[cid[3]];
7227
4/4
✓ Branch 0 taken 24512824 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 24510941 times.
✓ Branch 3 taken 1883 times.
24512827 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7228 {
7229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1883 times.
1883 if(cmb.usrflags&cflag1)
7230 hp_mod[3] = cmb.attributes[0] / -10000L;
7231 else
7232 1883 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1883 times.
1883 if(!(cmb.usrflags&cflag2))
7234 1883 hasKB |= 1<<3;
7235 1883 }
7236 }
7237
7238 24512827 int32_t bestcid=0;
7239 24512827 rpos_t best_rpos = rpos_t::None;
7240 24512827 int32_t hp_modtotal=0;
7241 24512827 rpos_t rposes[] = {COMBOPOS_REGION_B(dx1,dy1),COMBOPOS_REGION_B(dx1,dy2),COMBOPOS_REGION_B(dx2,dy1),COMBOPOS_REGION_B(dx2,dy2)};
7242
2/2
✓ Branch 0 taken 24384467 times.
✓ Branch 1 taken 128360 times.
24512827 if (!_effectflag(dx1,dy1,1, layer)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7243
2/2
✓ Branch 0 taken 24374507 times.
✓ Branch 1 taken 138320 times.
24512827 if (!_effectflag(dx1,dy2,1, layer)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7244
2/2
✓ Branch 0 taken 24384503 times.
✓ Branch 1 taken 128324 times.
24512827 if (!_effectflag(dx2,dy1,1, layer)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7245
2/2
✓ Branch 0 taken 24374541 times.
✓ Branch 1 taken 138286 times.
24512827 if (!_effectflag(dx2,dy2,1, layer)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7246
7247
2/2
✓ Branch 0 taken 49025654 times.
✓ Branch 1 taken 24512827 times.
73538481 for (int32_t i = 0; i <= 1; ++i)
7248 {
7249
2/2
✓ Branch 0 taken 44132314 times.
✓ Branch 1 taken 4893340 times.
49025654 if (get_qr(qr_OLD_BRIDGE_COMBOS))
7250 {
7251
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,i)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7252
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,i)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7253
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,i)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7254
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,i)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7255 44132314 }
7256 else
7257 {
7258
4/4
✓ Branch 0 taken 12191 times.
✓ Branch 1 taken 4881149 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 9653 times.
4893340 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,i)) {hp_mod[0] = 0; hasKB &= ~(1<<0);}
7259
4/4
✓ Branch 0 taken 12221 times.
✓ Branch 1 taken 4881119 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 9623 times.
4893340 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,i)) {hp_mod[1] = 0; hasKB &= ~(1<<1);}
7260
4/4
✓ Branch 0 taken 12212 times.
✓ Branch 1 taken 4881128 times.
✓ Branch 2 taken 2622 times.
✓ Branch 3 taken 9590 times.
4893340 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,i)) {hp_mod[2] = 0; hasKB &= ~(1<<2);}
7261
4/4
✓ Branch 0 taken 12245 times.
✓ Branch 1 taken 4881095 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 9560 times.
4893340 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,i)) {hp_mod[3] = 0; hasKB &= ~(1<<3);}
7262 }
7263 49025654 }
7264
7265
2/2
✓ Branch 0 taken 98051308 times.
✓ Branch 1 taken 24512827 times.
122564135 for(int32_t i=0; i<4; i++)
7266 {
7267
2/2
✓ Branch 0 taken 98048508 times.
✓ Branch 1 taken 2800 times.
98051308 if (rposes[i] == rpos_t::None)
7268 2800 continue;
7269
7270
2/2
✓ Branch 0 taken 37155700 times.
✓ Branch 1 taken 60892808 times.
98048508 if(get_qr(qr_DMGCOMBOPRI))
7271 {
7272
2/2
✓ Branch 0 taken 37155314 times.
✓ Branch 1 taken 386 times.
37155700 if(hp_modtotal >= 0) //Okay, if it's over 0, it's healing Hero.
7273 {
7274
2/2
✓ Branch 0 taken 37155156 times.
✓ Branch 1 taken 158 times.
37155314 if(hp_mod[i] < hp_modtotal)
7275 {
7276 158 hp_modtotal = hp_mod[i];
7277 158 bestcid = cid[i];
7278 158 best_rpos = rposes[i];
7279 158 }
7280 37155314 }
7281
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 298 times.
386 else if(hp_mod[i] < 0) //If it's under 0, it's hurting Hero.
7282 {
7283
1/2
✓ Branch 0 taken 298 times.
✗ Branch 1 not taken.
298 if(hp_mod[i] > hp_modtotal)
7284 {
7285 hp_modtotal = hp_mod[i];
7286 bestcid = cid[i];
7287 best_rpos = rposes[i];
7288 }
7289 298 }
7290 37155700 }
7291
2/2
✓ Branch 0 taken 60890884 times.
✓ Branch 1 taken 1924 times.
60892808 else if(hp_mod[i] < hp_modtotal)
7292 {
7293 1924 hp_modtotal = hp_mod[i];
7294 1924 bestcid = cid[i];
7295 1924 best_rpos = rposes[i];
7296 1924 }
7297 98048508 }
7298
7299 24512827 int ffc_ids[] = {-1, -1, -1, -1};
7300 {
7301 24512827 auto ffc_handle = getFFCAt(dx1,dy1);
7302
2/2
✓ Branch 0 taken 391979 times.
✓ Branch 1 taken 24120848 times.
24512827 ffc_ids[0] = ffc_handle ? ffc_handle->id : -1;
7303
2/2
✓ Branch 0 taken 391979 times.
✓ Branch 1 taken 24120848 times.
24512827 cid[4] = ffc_handle ? ffc_handle->data() : 0;
7304 24512827 newcombo& cmb = combobuf[cid[4]];
7305
4/4
✓ Branch 0 taken 24512632 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 24512584 times.
✓ Branch 3 taken 48 times.
24512827 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7306 {
7307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(cmb.usrflags&cflag1 )
7308 hp_mod[0] = cmb.attributes[0]/-10000L;
7309 else
7310 48 hp_mod[0]=combo_class_buf[cmb.type].modify_hp_amount;
7311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(!(cmb.usrflags&cflag2))
7312 48 hasKB |= 1<<4;
7313 48 }
7314 }
7315 {
7316 24512827 auto ffc_handle = getFFCAt(dx1,dy2);
7317
2/2
✓ Branch 0 taken 389118 times.
✓ Branch 1 taken 24123709 times.
24512827 ffc_ids[1] = ffc_handle ? ffc_handle->id : -1;
7318
2/2
✓ Branch 0 taken 389118 times.
✓ Branch 1 taken 24123709 times.
24512827 cid[5] = ffc_handle ? ffc_handle->data() : 0;
7319 24512827 newcombo& cmb = combobuf[cid[5]];
7320
4/4
✓ Branch 0 taken 24512623 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 24512579 times.
✓ Branch 3 taken 44 times.
24512827 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7321 {
7322
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(cmb.usrflags&cflag1 )
7323 hp_mod[1] = cmb.attributes[0]/-10000L;
7324 else
7325 44 hp_mod[1]=combo_class_buf[cmb.type].modify_hp_amount;
7326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(!(cmb.usrflags&cflag2))
7327 44 hasKB |= 1<<5;
7328 44 }
7329 }
7330 {
7331 24512827 auto ffc_handle = getFFCAt(dx2,dy1);
7332
2/2
✓ Branch 0 taken 396048 times.
✓ Branch 1 taken 24116779 times.
24512827 ffc_ids[2] = ffc_handle ? ffc_handle->id : -1;
7333
2/2
✓ Branch 0 taken 396048 times.
✓ Branch 1 taken 24116779 times.
24512827 cid[6] = ffc_handle ? ffc_handle->data() : 0;
7334 24512827 newcombo& cmb = combobuf[cid[6]];
7335
4/4
✓ Branch 0 taken 24512635 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 24512588 times.
✓ Branch 3 taken 47 times.
24512827 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7336 {
7337
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(cmb.usrflags&cflag1 )
7338 hp_mod[2] = cmb.attributes[0]/-10000L;
7339 else
7340 47 hp_mod[2]=combo_class_buf[cmb.type].modify_hp_amount;
7341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
47 if(!(cmb.usrflags&cflag2))
7342 47 hasKB |= 1<<6;
7343 47 }
7344 }
7345 {
7346 24512827 auto ffc_handle = getFFCAt(dx2,dy2);
7347
2/2
✓ Branch 0 taken 393151 times.
✓ Branch 1 taken 24119676 times.
24512827 ffc_ids[3] = ffc_handle ? ffc_handle->id : -1;
7348
2/2
✓ Branch 0 taken 393151 times.
✓ Branch 1 taken 24119676 times.
24512827 cid[7] = ffc_handle ? ffc_handle->data() : 0;
7349 24512827 newcombo& cmb = combobuf[cid[7]];
7350
4/4
✓ Branch 0 taken 24512626 times.
✓ Branch 1 taken 201 times.
✓ Branch 2 taken 24512581 times.
✓ Branch 3 taken 45 times.
24512827 if ( !(cmb.only_gentrig) && combo_class_buf[cmb.type].modify_hp_amount)
7351 {
7352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(cmb.usrflags&cflag1 )
7353 hp_mod[3] = cmb.attributes[0]/-10000L;
7354 else
7355 45 hp_mod[3]=combo_class_buf[cmb.type].modify_hp_amount;
7356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!(cmb.usrflags&cflag2))
7357 45 hasKB |= 1<<7;
7358 45 }
7359 }
7360
7361 24512827 int32_t bestffccid = 0;
7362 24512827 int best_ffcid = -1;
7363 24512827 int32_t hp_modtotalffc = 0;
7364
7365
2/2
✓ Branch 0 taken 49025654 times.
✓ Branch 1 taken 24512827 times.
73538481 for (int32_t i = 0; i <= 1; ++i)
7366 {
7367
2/2
✓ Branch 0 taken 44132314 times.
✓ Branch 1 taken 4893340 times.
49025654 if (get_qr(qr_OLD_BRIDGE_COMBOS))
7368 {
7369
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && !_walkflag_layer(dx1,dy1,i)) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && !_walkflag_layer(dx1,dy2,i)) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7371
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && !_walkflag_layer(dx2,dy1,i)) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 44132314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
44132314 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && !_walkflag_layer(dx2,dy2,i)) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7373 44132314 }
7374 else
7375 {
7376
4/4
✓ Branch 0 taken 12191 times.
✓ Branch 1 taken 4881149 times.
✓ Branch 2 taken 2538 times.
✓ Branch 3 taken 9653 times.
4893340 if (combobuf[MAPCOMBO2(i,dx1,dy1)].type == cBRIDGE && _effectflag_layer(dx1,dy1,i)) {hp_mod[0] = 0; hasKB &= ~(1<<4);}
7377
4/4
✓ Branch 0 taken 12221 times.
✓ Branch 1 taken 4881119 times.
✓ Branch 2 taken 2598 times.
✓ Branch 3 taken 9623 times.
4893340 if (combobuf[MAPCOMBO2(i,dx1,dy2)].type == cBRIDGE && _effectflag_layer(dx1,dy2,i)) {hp_mod[1] = 0; hasKB &= ~(1<<5);}
7378
4/4
✓ Branch 0 taken 12212 times.
✓ Branch 1 taken 4881128 times.
✓ Branch 2 taken 2622 times.
✓ Branch 3 taken 9590 times.
4893340 if (combobuf[MAPCOMBO2(i,dx2,dy1)].type == cBRIDGE && _effectflag_layer(dx2,dy1,i)) {hp_mod[2] = 0; hasKB &= ~(1<<6);}
7379
4/4
✓ Branch 0 taken 12245 times.
✓ Branch 1 taken 4881095 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 9560 times.
4893340 if (combobuf[MAPCOMBO2(i,dx2,dy2)].type == cBRIDGE && _effectflag_layer(dx2,dy2,i)) {hp_mod[3] = 0; hasKB &= ~(1<<7);}
7380 }
7381 49025654 }
7382
7383
2/2
✓ Branch 0 taken 98051308 times.
✓ Branch 1 taken 24512827 times.
122564135 for(int32_t i=0; i<4; i++)
7384 {
7385
2/2
✓ Branch 0 taken 1570296 times.
✓ Branch 1 taken 96481012 times.
98051308 if (ffc_ids[i] == -1) continue;
7386
7387
2/2
✓ Branch 0 taken 224165 times.
✓ Branch 1 taken 1346131 times.
1570296 if(get_qr(qr_DMGCOMBOPRI))
7388 {
7389
2/2
✓ Branch 0 taken 224049 times.
✓ Branch 1 taken 116 times.
224165 if(hp_modtotalffc >= 0)
7390 {
7391
2/2
✓ Branch 0 taken 223984 times.
✓ Branch 1 taken 65 times.
224049 if(hp_mod[i] < hp_modtotalffc)
7392 {
7393 65 hp_modtotalffc = hp_mod[i];
7394 65 bestffccid = cid[4+i];
7395 65 best_ffcid = ffc_ids[i];
7396 65 }
7397 224049 }
7398
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 112 times.
116 else if(hp_mod[i] < 0)
7399 {
7400
1/2
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
112 if(hp_mod[i] > hp_modtotalffc)
7401 {
7402 hp_modtotalffc = hp_mod[i];
7403 bestffccid = cid[4+i];
7404 best_ffcid = ffc_ids[i];
7405 }
7406 112 }
7407 224165 }
7408
2/2
✓ Branch 0 taken 1346105 times.
✓ Branch 1 taken 26 times.
1346131 else if(hp_mod[i] < hp_modtotalffc)
7409 {
7410 26 hp_modtotalffc = hp_mod[i];
7411 26 bestffccid = cid[4+i];
7412 26 best_ffcid = ffc_ids[i];
7413 26 }
7414 1570296 }
7415
7416 mapscr* damage_scr;
7417
2/2
✓ Branch 0 taken 2058 times.
✓ Branch 1 taken 24510769 times.
24512827 int32_t hp_modmin = zc_min(hp_modtotal, hp_modtotalffc);
7418 24512827 int best_type = 0;
7419
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 24512760 times.
24512827 if(hp_modtotalffc < hp_modtotal)
7420 {
7421 67 damage_scr = get_ffc_handle(best_ffcid).scr;
7422 67 bestcid = bestffccid;
7423 67 best_type = 1;
7424 67 }
7425 else
7426 {
7427 24512760 damage_scr = get_scr_for_rpos(best_rpos);
7428 }
7429
7430 24512827 bool global_defring = ((itemsbuf[current_item_id(itype_ring)].flags & item_flag1));
7431 24512827 bool global_perilring = ((itemsbuf[current_item_id(itype_perilring)].flags & item_flag1));
7432
7433 24512827 bool current_ring = ((hero_scr->flags6&fTOGGLERINGDAMAGE) != 0);
7434
1/2
✓ Branch 0 taken 24512827 times.
✗ Branch 1 not taken.
24512827 if(current_ring)
7435 {
7436 global_defring = !global_defring;
7437 global_perilring = !global_perilring;
7438 }
7439 24512827 int32_t itemid = current_item_id(itype_boots);
7440
7441
2/2
✓ Branch 0 taken 23530011 times.
✓ Branch 1 taken 982816 times.
24512827 bool bootsnosolid = itemid >= 0 && 0 != (itemsbuf[itemid].flags & item_flag1);
7442
2/2
✓ Branch 0 taken 23530011 times.
✓ Branch 1 taken 982816 times.
24512827 bool ignoreBoots = itemid >= 0 && (itemsbuf[itemid].flags & item_flag3);
7443
7444
2/2
✓ Branch 0 taken 24510688 times.
✓ Branch 1 taken 2139 times.
24512827 if(hp_modmin<0)
7445 {
7446
10/14
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 525 times.
✓ Branch 2 taken 1614 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1614 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1614 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 1609 times.
✓ Branch 10 taken 1614 times.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1614 times.
2139 if((itemid<0) || ignoreBoots || (damage_scr->flags5&fDAMAGEWITHBOOTS) || (4<<current_item_power(itype_boots)<(abs(hp_modmin))) || (solid && bootsnosolid) || !(checkbunny(itemid) && checkmagiccost(itemid)))
7447 {
7448
2/2
✓ Branch 0 taken 529 times.
✓ Branch 1 taken 6 times.
535 if (!do_health_check) return true;
7449 529 std::vector<int32_t> &ev = FFCore.eventData;
7450 529 ev.clear();
7451 529 ev.push_back(-hp_modmin*10000);
7452
1/2
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
529 ev.push_back((hasKB ? dir^1 : -1)*10000);
7453 529 ev.push_back(0);
7454 529 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7455 529 ev.push_back(48*10000);
7456 529 ev.push_back(ZSD_COMBODATA*10000);
7457 529 ev.push_back(bestcid);
7458 529 ev.push_back((best_type ? ZSD_FFC : ZSD_COMBOPOS)*10000);
7459
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 462 times.
529 ev.push_back((best_type ? best_ffcid : (int)best_rpos)*10000);
7460
7461 529 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7462 529 int32_t dmg = ev[0]/10000;
7463 529 bool nullhit = ev[2] != 0;
7464
7465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if(nullhit) {ev.clear(); return false;}
7466
7467 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7468 529 ev[0] = ringpower(dmg, !global_perilring, !global_defring)*10000;
7469
7470 529 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7471 529 dmg = ev[0]/10000;
7472 529 int32_t hdir = ev[1]/10000;
7473 529 nullhit = ev[2] != 0;
7474 529 bool divineprot = ev[3] != 0;
7475 529 int32_t iframes = ev[4] / 10000;
7476 529 ev.clear();
7477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if(nullhit) return false;
7478
7479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if(!divineprot)
7480 {
7481
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 19 times.
529 game->set_life(zc_max(game->get_life()-dmg,0));
7482 529 }
7483
7484 529 hitdir = hdir;
7485 529 doHit(hitdir, iframes);
7486 529 return true;
7487 }
7488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1614 times.
1614 else if (do_health_check) paymagiccost(itemid); // Boots are successful
7489 1614 }
7490
7491 24512302 return false;
7492 24515288 }
7493
7494 31136 int32_t HeroClass::hithero(int32_t hit2, int32_t force_hdir)
7495 {
7496
1/2
✓ Branch 0 taken 31136 times.
✗ Branch 1 not taken.
31136 if(force_hdir > 3) force_hdir = -1;
7497 31136 enemy* enemyptr = (enemy*)guys.spr(hit2);
7498
1/2
✓ Branch 0 taken 31136 times.
✗ Branch 1 not taken.
31136 if(!enemyptr) return 0;
7499 //printf("Stomp check: %d <= 12, %d < %d\n", int32_t((y+16)-(((enemy*)guys.spr(hit2))->y)), (int32_t)falling_oldy, (int32_t)y);
7500 31136 int32_t stompid = current_item_id(itype_stompboots);
7501
5/10
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 31119 times.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 17 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
31136 if(current_item(itype_stompboots) && checkbunny(stompid) && checkmagiccost(stompid) && (stomping ||
7502
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 ((z+fakez) > (enemyptr->z+(enemyptr->fakez))) ||
7503
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
17 ((isSideViewHero() && (y+16)-(enemyptr->y)<=14) && falling_oldy<y)))
7504 {
7505 paymagiccost(stompid);
7506 hit_enemy(hit2,wStomp,itemsbuf[stompid].power*game->get_hero_dmgmult(),x,y,0,stompid);
7507
7508 if(itemsbuf[stompid].flags & item_flag1)
7509 {
7510 fall = -(itemsbuf[stompid].misc1);
7511 }
7512
7513 if(itemsbuf[stompid].flags & item_downgrade)
7514 game->set_item(stompid,false);
7515
7516 // Stomp Boots script
7517 if(itemsbuf[stompid].script != 0 && !(FFCore.doscript(ScriptType::Item, stompid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
7518 {
7519 int i = stompid;
7520 FFCore.reset_script_engine_data(ScriptType::Item, i);
7521 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[stompid].script, i);
7522 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
7523 }
7524
7525 return -1;
7526 }
7527
6/6
✓ Branch 0 taken 26658 times.
✓ Branch 1 taken 4478 times.
✓ Branch 2 taken 25870 times.
✓ Branch 3 taken 788 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 25823 times.
31136 else if(superman || !scriptcoldet || fallclk)
7528 5313 return 0;
7529 //!TODO SOLIDPUSH Enemy flag to make them not deal contact damage
7530 //!Add a flag check to this if:
7531
5/6
✓ Branch 0 taken 9469 times.
✓ Branch 1 taken 16354 times.
✓ Branch 2 taken 9469 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2703 times.
✓ Branch 5 taken 6766 times.
25825 else if (!(enemyptr->stunclk==0 && enemyptr->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || enemyptr->fading != fade_flicker)
7532
4/4
✓ Branch 0 taken 2449 times.
✓ Branch 1 taken 254 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9213 times.
9469 && (enemyptr->d->type != eeGUY || enemyptr->dmisc1)))
7533 {
7534 16608 return -1;
7535 }
7536
7537 9215 std::vector<int32_t> &ev = FFCore.eventData;
7538 9215 ev.clear();
7539 //Args: 'damage (pre-ring)','hitdir','nullifyhit','type:npc','npc uid'
7540 9215 ev.push_back((enemy_dp(hit2) *10000));
7541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9215 times.
9215 ev.push_back((force_hdir>-1 ? force_hdir : ((sprite*)enemyptr)->hitdir(x,y,16,16,dir))*10000);
7542 9215 ev.push_back(0);
7543 9215 ev.push_back(DivineProtectionShieldClk>0?10000:0);
7544 9215 ev.push_back(48*10000);
7545 9215 ev.push_back(ZSD_NPC*10000);
7546 9215 ev.push_back(enemyptr->getUID());
7547 9215 ev.push_back(ZSD_NONE*10000);
7548 9215 ev.push_back(0);
7549
7550 9215 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
7551 9215 int32_t dmg = ev[0] / 10000;
7552 9215 bool nullhit = ev[2] != 0;
7553
7554
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9214 times.
9215 if(nullhit) {ev.clear(); return -1;}
7555
7556 //Args: 'damage (post-ring)','hitdir','nullifyhit','type:npc','npc uid'
7557 9214 ev[0] = ((ringpower(dmg)*10000));
7558
7559 9214 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
7560 9214 dmg = ev[0] / 10000;
7561 9214 int32_t hdir = ev[1] / 10000;
7562 9214 nullhit = ev[2] != 0;
7563 9214 bool divineprot = ev[3] != 0;
7564 9214 int32_t iframes = ev[4] / 10000;
7565 9214 ev.clear();
7566
7567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9214 times.
9214 if(nullhit) return -1;
7568
7569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9214 times.
9214 if(!divineprot)
7570 {
7571
2/2
✓ Branch 0 taken 9158 times.
✓ Branch 1 taken 56 times.
9214 game->set_life(zc_max(game->get_life()-dmg,0));
7572 9214 sethitHeroUID(HIT_BY_NPC,(hit2+1));
7573 9214 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7574 9214 sethitHeroUID(HIT_BY_NPC_UID,enemyptr->getUID());
7575 9214 sethitHeroUID(HIT_BY_NPC_ENGINE_UID,enemyptr->getUID());
7576 9214 sethitHeroUID(HIT_BY_NPC_ID, enemyptr->id);
7577 9214 sethitHeroUID(HIT_BY_NPC_TYPE, enemyptr->type);
7578 9214 }
7579
7580 9214 hitdir = hdir;
7581
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9214 times.
9214 if (IsSideSwim())
7582 {
7583 action=sideswimhit; FFCore.setHeroAction(sideswimhit);
7584 }
7585
3/4
✓ Branch 0 taken 9144 times.
✓ Branch 1 taken 70 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9144 times.
9214 else if(action==swimming || hopclk==0xFF)
7586 {
7587 70 action=swimhit; FFCore.setHeroAction(swimhit);
7588 70 }
7589 else
7590 {
7591 9144 action=gothit; FFCore.setHeroAction(gothit);
7592 }
7593
7594 9214 hclk=iframes;
7595 9214 check_on_hit();
7596 9214 sfx(getHurtSFX(),pan(x));
7597
7598
8/8
✓ Branch 0 taken 9190 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 9187 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 3775 times.
✓ Branch 5 taken 5412 times.
✓ Branch 6 taken 159 times.
✓ Branch 7 taken 3616 times.
9214 if(charging > 0 || spins > 0 || attack == wSword || attack == wHammer)
7599 {
7600 5598 spins = charging = attackclk = 0;
7601 5598 attack=none;
7602 5598 tapping = false;
7603 5598 }
7604
7605 9214 enemy_scored(hit2);
7606 9214 int32_t dm7 = enemyptr->dmisc7;
7607 9214 int32_t dm8 = enemyptr->dmisc8;
7608
7609
3/3
✓ Branch 0 taken 4524 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 4681 times.
9214 switch(enemyptr->type)
7610 {
7611 case eeWALLM:
7612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(enemyptr->hp>0)
7613 {
7614 9 GrabHero(hit2);
7615 9 inwallm=true;
7616 9 action=none; FFCore.setHeroAction(none);
7617 9 }
7618 9 break;
7619
7620 //case eBUBBLEST:
7621 //case eeBUBBLE:
7622 case eeWALK:
7623 {
7624 4681 int32_t itemid = current_item_id(itype_whispring);
7625 //I can only assume these are supposed to be int32_t, not bool ~pkmnfrk
7626
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
4681 int32_t sworddivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 1) ? itemsbuf[itemid].power : 1);
7627
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3806 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
4681 int32_t itemdivisor = ((itemid>-1 && itemsbuf[itemid].misc1 & 2) ? itemsbuf[itemid].power : 1);
7628
3/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 3806 times.
✓ Branch 2 taken 875 times.
✗ Branch 3 not taken.
4681 int32_t shielddivisor = ((itemid > -1 && itemsbuf[itemid].misc1 & 4) ? itemsbuf[itemid].power : 1);
7629
7/7
✓ Branch 0 taken 3800 times.
✓ Branch 1 taken 448 times.
✓ Branch 2 taken 145 times.
✓ Branch 3 taken 256 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 21 times.
✓ Branch 6 taken 6 times.
4681 switch(dm7)
7630 {
7631 case e7tTEMPJINX:
7632
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 400 times.
448 if(dm8&e8tSWORD)
7633
4/4
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 386 times.
786 if(swordclk>=0 && !(sworddivisor==0))
7634 386 swordclk=int32_t(150/sworddivisor);
7635
7636
2/2
✓ Branch 0 taken 398 times.
✓ Branch 1 taken 50 times.
448 if(dm8&e8tITEM)
7637
3/4
✓ Branch 0 taken 50 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 49 times.
99 if(itemclk>=0 && !(itemdivisor==0))
7638 49 itemclk=int32_t(150/itemdivisor);
7639
7640
1/2
✓ Branch 0 taken 448 times.
✗ Branch 1 not taken.
448 if(dm8&e8tSHIELD)
7641 if (shieldjinxclk >= 0 && !(shielddivisor==0))
7642 shieldjinxclk=int32_t(150/shielddivisor);
7643
7644 448 break;
7645
7646 case e7tPERMJINX:
7647
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 99 times.
145 if (dm8&e8tSWORD)
7648
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 93 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
99 if(sworddivisor) swordclk=(itemid >-1 && itemsbuf[itemid].flags & item_flag1)? int32_t(150/sworddivisor) : -1;
7649
7650
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 46 times.
145 if (dm8&e8tITEM)
7651
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
46 if(itemdivisor) itemclk=(itemid >-1 && itemsbuf[itemid].flags & item_flag1)? int32_t(150/itemdivisor) : -1;
7652
7653
1/2
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
145 if (dm8&e8tSHIELD)
7654 if(shielddivisor) shieldjinxclk=(itemid >-1 && itemsbuf[itemid].flags & item_flag1)? int32_t(150/shielddivisor) : -1;
7655
7656 145 break;
7657
7658 case e7tUNJINX:
7659
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 199 times.
256 if (dm8&e8tSWORD)
7660 199 swordclk=0;
7661
7662
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 76 times.
256 if (dm8&e8tITEM)
7663 76 itemclk=0;
7664
7665
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if (dm8&e8tSHIELD)
7666 shieldjinxclk=0;
7667
7668 256 break;
7669
7670 case e7tTAKEMAGIC:
7671 5 game->change_dmagic(-dm8*game->get_magicdrainrate());
7672 5 break;
7673
7674 case e7tTAKERUPEES:
7675 21 game->change_drupy(-dm8);
7676 21 break;
7677
7678 case e7tDRUNK:
7679 6 drunkclk += dm8;
7680 6 break;
7681 }
7682 4681 verifyAWpn();
7683
2/2
✓ Branch 0 taken 4543 times.
✓ Branch 1 taken 138 times.
4681 if(dm7 >= e7tEATITEMS)
7684 {
7685 138 EatHero(hit2);
7686 138 inlikelike=(dm7 == e7tEATHURT ? 2:1);
7687 138 action=none; FFCore.setHeroAction(none);
7688 138 }
7689 }
7690 4681 }
7691 9214 return 0;
7692 31136 }
7693
7694 515455 void HeroClass::addsparkle(int32_t wpn)
7695 {
7696 //return;
7697 515455 weapon *w = (weapon*)Lwpns.spr(wpn);
7698 515455 int32_t itemid = w->parentitem;
7699
7700
2/2
✓ Branch 0 taken 509694 times.
✓ Branch 1 taken 5761 times.
515455 if(itemid<0)
7701 5761 return;
7702
7703 509694 int32_t itemtype = itemsbuf[itemid].type;
7704
7705
4/4
✓ Branch 0 taken 509621 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 127430 times.
✓ Branch 3 taken 382191 times.
509694 if(itemtype!=itype_cbyrna && frame%4)
7706 382191 return;
7707
7708
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 127430 times.
127503 int32_t wpn2 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn4 : itemsbuf[itemid].wpn2;
7709
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 127430 times.
127503 int32_t wpn3 = (itemtype==itype_cbyrna) ? itemsbuf[itemid].wpn5 : itemsbuf[itemid].wpn3;
7710 // Either one (wpn2) or the other (wpn3). If both are present, randomise.
7711
5/8
✓ Branch 0 taken 37818 times.
✓ Branch 1 taken 89685 times.
✓ Branch 2 taken 69395 times.
✓ Branch 3 taken 20290 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 37818 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
127503 int32_t sparkle_type = (!wpn2 ? (!wpn3 ? 0 : wpn3) : (!wpn3 ? wpn2 : (zc_oldrand()&1 ? wpn2 : wpn3)));
7712 127503 int32_t direction=w->dir;
7713
7714
2/2
✓ Branch 0 taken 69395 times.
✓ Branch 1 taken 58108 times.
127503 if(sparkle_type)
7715 {
7716 58108 int32_t h=0;
7717 58108 int32_t v=0;
7718
7719
6/6
✓ Branch 0 taken 45868 times.
✓ Branch 1 taken 12240 times.
✓ Branch 2 taken 40776 times.
✓ Branch 3 taken 5092 times.
✓ Branch 4 taken 7701 times.
✓ Branch 5 taken 33075 times.
58108 if(w->dir==right||w->dir==r_up||w->dir==r_down)
7720 {
7721 25033 h=-1;
7722 25033 }
7723
7724
6/6
✓ Branch 0 taken 46277 times.
✓ Branch 1 taken 11831 times.
✓ Branch 2 taken 39583 times.
✓ Branch 3 taken 6694 times.
✓ Branch 4 taken 5719 times.
✓ Branch 5 taken 33864 times.
58108 if(w->dir==left||w->dir==l_up||w->dir==l_down)
7725 {
7726 24244 h=1;
7727 24244 }
7728
7729
6/6
✓ Branch 0 taken 54209 times.
✓ Branch 1 taken 3899 times.
✓ Branch 2 taken 48490 times.
✓ Branch 3 taken 5719 times.
✓ Branch 4 taken 7701 times.
✓ Branch 5 taken 40789 times.
58108 if(w->dir==down||w->dir==l_down||w->dir==r_down)
7730 {
7731 17319 v=-1;
7732 17319 }
7733
7734
6/6
✓ Branch 0 taken 53176 times.
✓ Branch 1 taken 4932 times.
✓ Branch 2 taken 46482 times.
✓ Branch 3 taken 6694 times.
✓ Branch 4 taken 5092 times.
✓ Branch 5 taken 41390 times.
58108 if(w->dir==up||w->dir==l_up||w->dir==r_up)
7735 {
7736 16718 v=1;
7737 16718 }
7738
7739 // Damaging boomerang sparkle?
7740
3/4
✓ Branch 0 taken 20290 times.
✓ Branch 1 taken 37818 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20290 times.
58108 if(wpn3 && itemtype==itype_brang)
7741 {
7742 // If the boomerang just bounced, flip the sparkle direction so it doesn't hit
7743 // whatever it just bounced off of if it's shielded from that direction.
7744
6/6
✓ Branch 0 taken 13240 times.
✓ Branch 1 taken 7050 times.
✓ Branch 2 taken 12389 times.
✓ Branch 3 taken 851 times.
✓ Branch 4 taken 5382 times.
✓ Branch 5 taken 7007 times.
20290 if(w->misc==1 && w->clk2>256 && w->clk2<272)
7745 7007 direction=oppositeDir[direction];
7746 20290 }
7747
4/4
✓ Branch 0 taken 53757 times.
✓ Branch 1 taken 4351 times.
✓ Branch 2 taken 24015 times.
✓ Branch 3 taken 29742 times.
58108 if(itemtype==itype_brang && get_qr(qr_WRONG_BRANG_TRAIL_DIR)) direction = 0;
7748
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 58035 times.
58108 zfix x = w->x+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(h*4);
7749
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 58035 times.
58108 zfix y = w->y+(itemtype==itype_cbyrna ? 2 : zc_oldrand()%4)+(v*4)-w->fakez;
7750
5/10
✓ Branch 0 taken 58108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58108 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58108 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58108 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58108 times.
✗ Branch 9 not taken.
58108 Lwpns.add(new weapon(x, y, w->z, sparkle_type==wpn3 ? wFSparkle : wSSparkle,sparkle_type,0,direction,itemid,getUID(),false,false,true, 0, sparkle_type));
7751 58108 weapon *w = (weapon*)(Lwpns.spr(Lwpns.Count()-1));
7752 58108 }
7753 515455 }
7754
7755 // For wPhantoms
7756 7410 void HeroClass::addsparkle2(int32_t type1, int32_t type2)
7757 {
7758
2/2
✓ Branch 0 taken 5586 times.
✓ Branch 1 taken 1824 times.
7410 if(frame%4) return;
7759
7760 1824 int32_t arrow = -1;
7761
7762
2/2
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 10041 times.
11561 for(int32_t i=0; i<Lwpns.Count(); i++)
7763 {
7764 10041 weapon *w = (weapon*)Lwpns.spr(i);
7765
7766
4/4
✓ Branch 0 taken 6249 times.
✓ Branch 1 taken 3792 times.
✓ Branch 2 taken 5945 times.
✓ Branch 3 taken 304 times.
10041 if(w->id == wPhantom && w->level == type1)
7767 {
7768 304 arrow = i;
7769 304 break;
7770 }
7771 9737 }
7772
7773
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 1520 times.
1824 if(arrow==-1)
7774 {
7775 1520 return;
7776 }
7777
7778 304 zfix x = (Lwpns.spr(arrow)->x-3)+(zc_oldrand()%7);
7779 304 zfix y = (Lwpns.spr(arrow)->y-3)+(zc_oldrand()%7)-Lwpns.spr(arrow)->fakez;
7780
6/12
✓ Branch 0 taken 304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 304 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 304 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 304 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 304 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 304 times.
✗ Branch 11 not taken.
304 Lwpns.add(new weapon(x, y, Lwpns.spr(arrow)->z, wPhantom, type2,0,0,((weapon*)Lwpns.spr(arrow))->parentitem,-1));
7781 7410 }
7782
7783 //cleans up decorations that exit the bounds of the screen for a int32_t time, to prevebt them wrapping around.
7784 14307772 void HeroClass::PhantomsCleanup()
7785 {
7786
2/2
✓ Branch 0 taken 5097860 times.
✓ Branch 1 taken 14307772 times.
19405632 for(int32_t i=0; i<Lwpns.Count(); i++)
7787 {
7788 5097860 weapon *w = ((weapon *)Lwpns.spr(i));
7789
3/4
✓ Branch 0 taken 4869 times.
✓ Branch 1 taken 5092991 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4869 times.
5097860 if ( w->id == wPhantom && !w->isScriptGenerated() )
7790 {
7791
4/8
✓ Branch 0 taken 4869 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4869 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4869 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 4869 times.
4869 if ( w->x < -10000 || w->y > 10000 || w->x < -10000 || w->y > 10000 )
7792 {
7793 Lwpns.remove(w);
7794 }
7795 4869 }
7796 5097860 }
7797 14307772 }
7798
7799 //Waitframe handler for refilling operations
7800 6288 static void do_refill_waitframe()
7801 {
7802 6288 put_passive_subscr(framebuf,0,0,game->should_show_time(),sspUP);
7803
1/2
✓ Branch 0 taken 6288 times.
✗ Branch 1 not taken.
6288 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
7804 {
7805 script_drawing_commands.Clear();
7806 if(DMaps[cur_dmap].passive_sub_script != 0)
7807 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script, cur_dmap);
7808
7809 if (FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[cur_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
7810 {
7811 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script, cur_dmap);
7812 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
7813 }
7814 do_script_draws(framebuf, origin_scr, 0, playing_field_offset);
7815 }
7816 6288 advanceframe(true);
7817 6288 }
7818 //Special handler if it's a "fairy revive"
7819 static void do_death_refill_waitframe()
7820 {
7821 //!TODO Run a new script slot each frame here, before calling do_refill_waitframe()
7822 //This script should be able to draw a 'fairy saving the player' animation -Em
7823 do_refill_waitframe();
7824 }
7825
7826 1 static size_t find_bottle_for_slot(size_t slot, bool unowned=false)
7827 {
7828 1 int32_t found_unowned = -1;
7829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
153 for(int q = 0; q < MAXITEMS; ++q)
7830 {
7831
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
153 if(itemsbuf[q].type == itype_bottle && itemsbuf[q].misc1 == slot)
7832 {
7833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_item(q))
7834 1 return q;
7835 if(unowned)
7836 found_unowned = q;
7837 }
7838 152 }
7839 return found_unowned;
7840 1 }
7841
7842 int32_t getPushDir(int32_t flag)
7843 {
7844 switch(flag)
7845 {
7846 case mfPUSHUD: case mfPUSH4: case mfPUSHU: case mfPUSHUDNS:
7847 case mfPUSH4NS: case mfPUSHUNS: case mfPUSHUDINS: case mfPUSH4INS:
7848 case mfPUSHUINS:
7849 return up;
7850 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
7851 return down;
7852 case mfPUSHLR: case mfPUSHL: case mfPUSHLRNS: case mfPUSHLNS:
7853 case mfPUSHLRINS: case mfPUSHLINS:
7854 return left;
7855 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
7856 return right;
7857 }
7858 return -1;
7859 }
7860
7861 void post_item_collect();
7862
7863 14309410 bool HeroClass::handle_portal_collide(portal* p)
7864 {
7865
1/2
✓ Branch 0 taken 14309410 times.
✗ Branch 1 not taken.
14309410 if(!p) return false;
7866 14309410 p->animate(0);
7867
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14309410 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14309410 if(p->destdmap < 0 || p->destdmap >= MAXDMAPS)
7868 14309410 return false;
7869 if(abs(x - p->x) < 12
7870 && abs(y - p->y) < 12)
7871 {
7872 if(p->prox_active)
7873 {
7874 //Store some values to restore if 'warp fails'
7875 int32_t tLastEntrance = lastentrance,
7876 tLastEntranceDMap = lastentrance_dmap,
7877 tContScr = game->get_continue_scrn(),
7878 tContDMap = game->get_continue_dmap();
7879 int32_t sourcescr = cur_screen, sourcedmap = cur_dmap;
7880 zfix tx = x, ty = y, tz = z;
7881 x = p->x;
7882 y = p->y;
7883
7884 int32_t weff = p->weffect,
7885 wsfx = p->wsfx;
7886
7887 int32_t savep = p->saved_data;
7888 //After this line, 'p' becomes INVALID!
7889 FFCore.warp_player(wtIWARP, p->destdmap, p->destscr,
7890 -1, -1, weff, wsfx, 0, -1);
7891
7892 if(mirrorBonk()) //Invalid landing, warp back!
7893 {
7894 action = none; FFCore.setHeroAction(none);
7895 lastentrance = tLastEntrance;
7896 lastentrance_dmap = tLastEntranceDMap;
7897 game->set_continue_scrn(tContScr);
7898 game->set_continue_dmap(tContDMap);
7899 x = tx;
7900 y = ty;
7901 z = tz;
7902 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, weff,
7903 wsfx, 0, -1);
7904 handle_portal_prox(&mirror_portal);
7905 portals.forEach([&](sprite& p)
7906 {
7907 handle_portal_prox((portal*)&p);
7908 return false;
7909 });
7910 }
7911 else game->clear_portal(savep); //Remove portal once used
7912 return true;
7913 }
7914 }
7915 else p->prox_active = true;
7916 return false;
7917 14309410 }
7918 145 void HeroClass::handle_portal_prox(portal* p)
7919 {
7920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 if(!p) return;
7921
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 23 times.
145 p->prox_active = !(abs(x - p->x) < 12 && abs(y - p->y) < 12);
7922 145 }
7923 // returns true when game over
7924 14346856 bool HeroClass::animate(int32_t)
7925 {
7926 14346856 update_current_screen();
7927
7928 14346856 int32_t lsave=0;
7929
1/2
✓ Branch 0 taken 14346856 times.
✗ Branch 1 not taken.
14346856 if(immortal > 0)
7930 --immortal;
7931 14346856 prompt_combo = 0;
7932
2/2
✓ Branch 0 taken 38069 times.
✓ Branch 1 taken 14308787 times.
14346856 if (onpassivedmg)
7933 {
7934 38069 onpassivedmg=false;
7935 38069 }
7936
2/2
✓ Branch 0 taken 14308782 times.
✓ Branch 1 taken 5 times.
14308787 else if (damageovertimeclk)
7937 {
7938 5 damageovertimeclk = 0;
7939 5 }
7940
7941
2/2
✓ Branch 0 taken 14336450 times.
✓ Branch 1 taken 10406 times.
14346856 if(lift_wpn)
7942 {
7943 10406 auto oldid = lift_wpn->id;
7944
2/2
✓ Branch 0 taken 923 times.
✓ Branch 1 taken 9483 times.
10406 switch(lift_wpn->id)
7945 {
7946 case wLitBomb:
7947 case wBomb:
7948 case wLitSBomb:
7949 case wSBomb:
7950
2/4
✓ Branch 0 taken 923 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 923 times.
923 if(lift_wpn->misc && get_qr(qr_HELD_BOMBS_EXPLODE)) //timed fuse
7951 {
7952 923 lift_wpn->limited_animate();
7953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 923 times.
923 if(lift_wpn->id != oldid)
7954 {
7955 lift_wpn->moveflags &= ~move_obeys_grav;
7956 drop_liftwpn();
7957 goto heroanimate_skip_liftwpn;
7958 }
7959 923 ++lift_wpn->clk;
7960 923 }
7961 923 break;
7962 }
7963
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
10406 if(lift_wpn->dead>0)
7964 --lift_wpn->dead;
7965
7966
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
10406 if(get_qr(qr_LIFTED_WEAPONS_RUN_SCRIPTS))
7967 lift_wpn->run_script(MODE_NORMAL);
7968
7969
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
10406 if(lift_wpn->dead==0)
7970 {
7971 if(lift_wpn->death_spawnitem > -1)
7972 {
7973 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, lift_wpn->death_spawnitem, lift_wpn->death_item_pflags, 0));
7974 itm->fakez = lift_wpn->fakez;
7975 items.add(itm);
7976 }
7977 if(lift_wpn->death_spawndropset > -1)
7978 {
7979 auto itid = select_dropitem(lift_wpn->death_spawndropset);
7980 if(itid > -1)
7981 {
7982 item* itm = (new item(lift_wpn->x, lift_wpn->y, lift_wpn->z, itid, lift_wpn->death_item_pflags, 0));
7983 itm->fakez = lift_wpn->fakez;
7984 itm->from_dropset = lift_wpn->death_spawndropset;
7985 items.add(itm);
7986 }
7987 }
7988 switch(lift_wpn->death_sprite)
7989 {
7990 case -2: decorations.add(new dBushLeaves(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dBUSHLEAVES, 0, 0)); break;
7991 case -3: decorations.add(new dFlowerClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dFLOWERCLIPPINGS, 0, 0)); break;
7992 case -4: decorations.add(new dGrassClippings(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dGRASSCLIPPINGS, 0, 0)); break;
7993 default:
7994 if(lift_wpn->death_sprite < 0) break;
7995 decorations.add(new comboSprite(lift_wpn->x, lift_wpn->y-(lift_wpn->z+lift_wpn->fakez), dCOMBOSPRITE, 0, lift_wpn->death_sprite));
7996 }
7997 if(lift_wpn->death_sfx > 0)
7998 sfx(lift_wpn->death_sfx, pan(int32_t(lift_wpn->x)));
7999 delete lift_wpn;
8000 lift_wpn = nullptr;
8001 }
8002 heroanimate_skip_liftwpn:;
8003 10406 }
8004
8005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14346856 times.
14346856 if(cheats_execute_goto)
8006 {
8007 setpit();
8008 dowarp(hero_scr, 3, 0);
8009 cheats_execute_goto=false;
8010 solid_update(false);
8011 return false;
8012 }
8013
8014
1/2
✓ Branch 0 taken 14346856 times.
✗ Branch 1 not taken.
14346856 if(cheats_execute_light)
8015 {
8016 toggle_lights(pal_litOVERRIDE); //Forcibly set permLit, overriding its current setting
8017 cheats_execute_light = false;
8018 }
8019
8020
3/4
✓ Branch 0 taken 14309410 times.
✓ Branch 1 taken 37446 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14309410 times.
14346856 if(action!=climbcovertop&&action!=climbcoverbottom)
8021 {
8022 14309410 climb_cover_x=-1000;
8023 14309410 climb_cover_y=-1000;
8024 14309410 }
8025
8026 14346856 handle_portal_collide(&mirror_portal);
8027
1/2
✓ Branch 0 taken 14346856 times.
✗ Branch 1 not taken.
14346856 portals.forEach([&](sprite& p)
8028 {
8029 return handle_portal_collide((portal*)&p);
8030 });
8031
8032
3/4
✓ Branch 0 taken 14292672 times.
✓ Branch 1 taken 54184 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14292672 times.
14346856 if(z<=8&&fakez<=8) //Tall Grass
8033 {
8034 14292672 int maxlyr = get_qr(qr_BUSHESONLAYERS1AND2) ? 2 : 0;
8035
2/2
✓ Branch 0 taken 632362 times.
✓ Branch 1 taken 13660310 times.
14292672 if (get_qr(qr_GRASS_SENSITIVE))
8036 {
8037 632362 bool g1 = false, g2 = false, g3 = false, g4 = false;
8038
2/2
✓ Branch 0 taken 1814024 times.
✓ Branch 1 taken 632362 times.
2446386 for(int q = maxlyr; q >= 0; --q)
8039 {
8040
2/2
✓ Branch 0 taken 2282 times.
✓ Branch 1 taken 1811742 times.
1814024 g1 = g1 || isGrassType(combobuf[MAPCOMBO2(q-1,x+4,y+15)].type);
8041
2/2
✓ Branch 0 taken 2251 times.
✓ Branch 1 taken 1811773 times.
1814024 g2 = g2 || isGrassType(combobuf[MAPCOMBO2(q-1,x+11,y+15)].type);
8042
2/2
✓ Branch 0 taken 2323 times.
✓ Branch 1 taken 1811701 times.
1814024 g3 = g3 || isGrassType(combobuf[MAPCOMBO2(q-1,x+4,y+9)].type);
8043
2/2
✓ Branch 0 taken 2350 times.
✓ Branch 1 taken 1811674 times.
1814024 g4 = g4 || isGrassType(combobuf[MAPCOMBO2(q-1,x+11,y+9)].type);
8044 1814024 }
8045
8/8
✓ Branch 0 taken 8260 times.
✓ Branch 1 taken 624102 times.
✓ Branch 2 taken 7135 times.
✓ Branch 3 taken 1125 times.
✓ Branch 4 taken 6227 times.
✓ Branch 5 taken 908 times.
✓ Branch 6 taken 62 times.
✓ Branch 7 taken 6165 times.
632362 if(g1 && g2 && g3 && g4)
8046 {
8047 6165 int grasscid = 0;
8048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16508 times.
16508 for(int q = maxlyr; q >= 0; --q)
8049 {
8050 16508 int cid = MAPCOMBO2(q-1,x+8,y+12);
8051
4/4
✓ Branch 0 taken 7637 times.
✓ Branch 1 taken 8871 times.
✓ Branch 2 taken 1472 times.
✓ Branch 3 taken 6165 times.
16508 if(cid > 0 && isGrassType(combobuf[cid].type))
8052 {
8053 6165 grasscid = cid;
8054 6165 break;
8055 }
8056 10343 }
8057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6165 times.
6165 if(grasscid)
8058 {
8059 6165 newcombo const& cmb = combobuf[grasscid];
8060
2/2
✓ Branch 0 taken 5003 times.
✓ Branch 1 taken 1162 times.
6165 if(decorations.idCount(dTALLGRASS)==0)
8061 {
8062
3/6
✓ Branch 0 taken 1162 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1162 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1162 times.
✗ Branch 5 not taken.
1162 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
8063 1162 }
8064 6165 int32_t thesfx = cmb.attribytes[3];
8065
2/2
✓ Branch 0 taken 2035 times.
✓ Branch 1 taken 4130 times.
6165 if (action==walking)
8066 4130 sfx_no_repeat(thesfx,pan((int32_t)x));
8067 6165 }
8068 6165 }
8069 632362 }
8070 else
8071 {
8072 13660310 bool g1 = false, g2 = false;
8073
2/2
✓ Branch 0 taken 14066926 times.
✓ Branch 1 taken 13660310 times.
27727236 for(int q = maxlyr; q >= 0; --q)
8074 {
8075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14066926 times.
14066926 g1 = g1 || isGrassType(combobuf[MAPCOMBO2(q-1,x,y+15)].type);
8076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14066926 times.
14066926 g2 = g2 || isGrassType(combobuf[MAPCOMBO2(q-1,x+15,y+15)].type);
8077 14066926 }
8078
4/4
✓ Branch 0 taken 141631 times.
✓ Branch 1 taken 13518679 times.
✓ Branch 2 taken 30796 times.
✓ Branch 3 taken 110835 times.
13660310 if(g1 && g2)
8079 {
8080 110835 int grasscid = 0;
8081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124915 times.
124915 for(int q = maxlyr; q >= 0; --q)
8082 {
8083 124915 int cid = MAPCOMBO2(q-1,x+8,y+15);
8084
3/4
✓ Branch 0 taken 110835 times.
✓ Branch 1 taken 14080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 110835 times.
124915 if(cid > 0 && isGrassType(combobuf[cid].type))
8085 {
8086 110835 grasscid = cid;
8087 110835 break;
8088 }
8089 14080 }
8090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110835 times.
110835 if(grasscid)
8091 {
8092 110835 newcombo const& cmb = combobuf[grasscid];
8093
2/2
✓ Branch 0 taken 108195 times.
✓ Branch 1 taken 2640 times.
110835 if(decorations.idCount(dTALLGRASS)==0)
8094 {
8095
3/6
✓ Branch 0 taken 2640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2640 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2640 times.
✗ Branch 5 not taken.
2640 decorations.add(new dTallGrass(x, y, dTALLGRASS, 0, cmb.attribytes[6]));
8096 2640 }
8097 110835 int32_t thesfx = cmb.attribytes[3];
8098
2/2
✓ Branch 0 taken 39735 times.
✓ Branch 1 taken 71100 times.
110835 if (action==walking )
8099 71100 sfx_no_repeat(thesfx,pan((int32_t)x));
8100 110835 }
8101 110835 }
8102 }
8103 14292672 }
8104
3/4
✓ Branch 0 taken 14290287 times.
✓ Branch 1 taken 56569 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14290287 times.
14346856 if(z==0 && fakez==0) //Shallow Water / Custom Walk SFX
8105 {
8106
2/2
✓ Branch 0 taken 1177673 times.
✓ Branch 1 taken 13112614 times.
14290287 if (get_qr(qr_SHALLOW_SENSITIVE))
8107 {
8108
18/22
✓ Branch 0 taken 1169618 times.
✓ Branch 1 taken 8055 times.
✓ Branch 2 taken 1169618 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1165362 times.
✓ Branch 5 taken 4256 times.
✓ Branch 6 taken 1165106 times.
✓ Branch 7 taken 256 times.
✓ Branch 8 taken 1165106 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1165106 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1161536 times.
✓ Branch 13 taken 3570 times.
✓ Branch 14 taken 1161536 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1161503 times.
✓ Branch 17 taken 33 times.
✓ Branch 18 taken 1151092 times.
✓ Branch 19 taken 10411 times.
✓ Branch 20 taken 1547 times.
✓ Branch 21 taken 1149545 times.
1177673 if (action != swimming && action != isdiving && action != drowning && action!=lavadrowning && action!=sidedrowning && action!=rafting && action != falling && !IsSideSwim() && !(ladderx+laddery) && !pull_hero && !toogam)
8109 {
8110 1149545 bool b1 = iswaterex_z3(FFORCOMBO(x+11,y+15), -1, x+11, y+15, false, false, true, true);
8111 1149545 bool b2 = iswaterex_z3(FFORCOMBO(x+4,y+15), -1, x+4, y+15, false, false, true, true);
8112 1149545 bool b3 = iswaterex_z3(FFORCOMBO(x+11,y+9), -1, x+11, y+9, false, false, true, true);
8113 1149545 bool b4 = iswaterex_z3(FFORCOMBO(x+4,y+9), -1, x+4, y+9, false, false, true, true);
8114
8115
8/8
✓ Branch 0 taken 60555 times.
✓ Branch 1 taken 1088990 times.
✓ Branch 2 taken 56317 times.
✓ Branch 3 taken 4238 times.
✓ Branch 4 taken 52954 times.
✓ Branch 5 taken 3363 times.
✓ Branch 6 taken 146 times.
✓ Branch 7 taken 52808 times.
1149545 if (b1 && b2 && b3 && b4)
8116 {
8117 52808 int watercheck_x = x.getInt()+7.5, watercheck_y = y.getInt()+12;
8118 52808 auto combined_handle = get_combined_handle_for_world_xy(watercheck_x, watercheck_y, 0);
8119 52808 int waterid = combined_handle.data();
8120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 if(waterid)
8121 52808 waterid = iswaterex_z3(waterid, -1, watercheck_x,watercheck_y, false, false, true, true);
8122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52808 times.
52808 if(waterid)
8123 {
8124 52808 newcombo const& watercmb = combobuf[waterid];
8125 52808 auto ripplesprite = watercmb.attribytes[6];
8126
2/2
✓ Branch 0 taken 52361 times.
✓ Branch 1 taken 447 times.
52808 if(decorations.idCount(dRIPPLES)==0)
8127
3/6
✓ Branch 0 taken 447 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 447 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 447 times.
✗ Branch 5 not taken.
447 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
8128
2/2
✓ Branch 0 taken 623 times.
✓ Branch 1 taken 52185 times.
52808 if (watercmb.usrflags&cflag2)
8129 {
8130
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 623 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
623 if (!(current_item(watercmb.attribytes[2]) > 0 && current_item(watercmb.attribytes[2]) >= watercmb.attribytes[3]))
8131 {
8132 623 onpassivedmg = true;
8133
2/2
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 314 times.
623 if (!damageovertimeclk)
8134 {
8135 314 int32_t curhp = game->get_life();
8136 314 auto dmg = watercmb.attributes[1]/10000L;
8137 314 auto hitsfx = watercmb.attributes[2]/10000L;
8138
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 bool hitstun = dmg < 0 && (watercmb.usrflags&cflag7);
8139
8140
2/4
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 314 times.
314 if(game->get_life() == curhp && (watercmb.usrflags&cflag6))
8141 314 hitsfx = 0;
8142
8143 314 std::vector<int32_t> &ev = FFCore.eventData;
8144 314 ev.clear();
8145 314 ev.push_back(-dmg*10000);
8146 314 ev.push_back(-1*10000);
8147 314 ev.push_back(0);
8148 314 ev.push_back(0);
8149 314 ev.push_back(48*10000);
8150 314 ev.push_back(ZSD_COMBODATA*10000);
8151 314 ev.push_back(waterid);
8152 314 ev.push_back((combined_handle.is_ffc() ? ZSD_FFC : ZSD_COMBOPOS)*10000);
8153 314 ev.push_back(combined_handle.id()*10000);
8154
8155 314 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_1);
8156
8157
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(watercmb.usrflags & cflag5)
8158 ev[0] = ringpower(ev[0]/10000) * 10000;
8159
8160 314 throwGenScriptEvent(GENSCR_EVENT_HERO_HIT_2);
8161 314 dmg = -ev[0]/10000;
8162
8163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 if(!ev[2]) //nullify
8164 {
8165 314 game->set_life(vbound(game->get_life()+dmg, 0, game->get_maxlife()));
8166
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if (hitsfx)
8167 sfx(hitsfx);
8168
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if (hitstun)
8169 {
8170 hclk = ev[4]/10000;
8171 hitdir = ev[1]/10000;
8172 action = gothit; FFCore.setHeroAction(gothit);
8173 check_on_hit();
8174 }
8175 314 }
8176 314 }
8177
1/2
✓ Branch 0 taken 623 times.
✗ Branch 1 not taken.
623 if (watercmb.attribytes[1] > 0)
8178 {
8179
3/4
✓ Branch 0 taken 309 times.
✓ Branch 1 taken 314 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 309 times.
623 if (!damageovertimeclk || damageovertimeclk > watercmb.attribytes[1]) damageovertimeclk = watercmb.attribytes[1];
8180 309 else --damageovertimeclk;
8181 623 }
8182 else damageovertimeclk = 0;
8183 623 }
8184 else damageovertimeclk = 0;
8185 623 }
8186 52185 else damageovertimeclk = 0;
8187 52808 int32_t thesfx = watercmb.attribytes[0];
8188
4/4
✓ Branch 0 taken 51858 times.
✓ Branch 1 taken 950 times.
✓ Branch 2 taken 46233 times.
✓ Branch 3 taken 5625 times.
52808 if (watercmb.type != cSHALLOWWATER || !get_qr(qr_OLD_SHALLOW_SFX))
8189 {
8190 6575 thesfx = watercmb.attribytes[5];
8191 6575 }
8192
2/2
✓ Branch 0 taken 28715 times.
✓ Branch 1 taken 24093 times.
52808 if (action==walking)
8193 24093 sfx_no_repeat(thesfx,pan((int32_t)x));
8194 52808 }
8195 52808 }
8196 1149545 }
8197 1177673 }
8198 else
8199 {
8200
4/4
✓ Branch 0 taken 12956578 times.
✓ Branch 1 taken 156036 times.
✓ Branch 2 taken 12969911 times.
✓ Branch 3 taken 142703 times.
13112614 if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER))
8201 {
8202 142703 int32_t watercheck = FFORCOMBO(x+7.5,y.getInt()+15);
8203 142703 auto ripplesprite = combobuf[watercheck].attribytes[6];
8204
2/2
✓ Branch 0 taken 141287 times.
✓ Branch 1 taken 1416 times.
142703 if(decorations.idCount(dRIPPLES)==0)
8205 {
8206
3/6
✓ Branch 0 taken 1416 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1416 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1416 times.
✗ Branch 5 not taken.
1416 decorations.add(new dRipples(x, y, dRIPPLES, 0, ripplesprite));
8207 1416 }
8208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142703 times.
142703 if (combobuf[watercheck].usrflags&cflag2)
8209 {
8210 if (!(current_item(combobuf[watercheck].attribytes[2]) > 0 && current_item(combobuf[watercheck].attribytes[2]) >= combobuf[watercheck].attribytes[3]))
8211 {
8212 onpassivedmg = true;
8213 if (!damageovertimeclk)
8214 {
8215 int32_t curhp = game->get_life();
8216 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
8217 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
8218 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
8219 }
8220 if (combobuf[watercheck].attribytes[1] > 0)
8221 {
8222 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
8223 else --damageovertimeclk;
8224 }
8225 else damageovertimeclk = 0;
8226 }
8227 else damageovertimeclk = 0;
8228 }
8229 142703 else damageovertimeclk = 0;
8230 142703 int32_t thesfx = combobuf[watercheck].attribytes[0];
8231
2/2
✓ Branch 0 taken 53531 times.
✓ Branch 1 taken 89172 times.
142703 if (action==walking )
8232 89172 sfx_no_repeat(thesfx,pan((int32_t)x));
8233 142703 }
8234 }
8235
8236 14290287 auto rpos = COMBOPOS_REGION_B(x+8,y+(sideview_mode()?16:12));
8237
2/2
✓ Branch 0 taken 14289133 times.
✓ Branch 1 taken 100025085 times.
114314218 for(int q = 0; q < 7; ++q)
8238 {
8239
2/2
✓ Branch 0 taken 1154 times.
✓ Branch 1 taken 100023931 times.
100025085 if (rpos == rpos_t::None)
8240 1154 break;
8241
8242 100023931 auto rpos_handle = get_rpos_handle(rpos, q);
8243 100023931 auto& cmb = rpos_handle.combo();
8244
2/2
✓ Branch 0 taken 53042066 times.
✓ Branch 1 taken 46981865 times.
100023931 byte csfx = action == walking ? cmb.sfx_walking : cmb.sfx_standing;
8245
2/2
✓ Branch 0 taken 53042066 times.
✓ Branch 1 taken 46981865 times.
100023931 byte cspr = action == walking ? cmb.spr_walking : cmb.spr_standing;
8246
2/2
✓ Branch 0 taken 100014307 times.
✓ Branch 1 taken 9624 times.
100023931 if(csfx)
8247 9624 sfx_no_repeat(csfx);
8248 100023931 auto indx = decorations.idFirst(dCUSTOMWALK);
8249
1/2
✓ Branch 0 taken 100023931 times.
✗ Branch 1 not taken.
100023931 if(cspr)
8250 {
8251 if(indx < 0)
8252 {
8253 if(decorations.add(new customWalkSprite(x, y, dCUSTOMWALK, 0, -1)))
8254 indx = decorations.Count()-1;
8255 }
8256 if(indx > -1)
8257 {
8258 if(customWalkSprite* spr = dynamic_cast<customWalkSprite*>(decorations.spr(indx)))
8259 spr->run_sprite(cspr);
8260 }
8261 }
8262 100023931 }
8263 14290287 }
8264
8265
2/2
✓ Branch 0 taken 14346431 times.
✓ Branch 1 taken 425 times.
14346856 if(stomping)
8266 425 stomping = false;
8267
8268
2/2
✓ Branch 0 taken 14346545 times.
✓ Branch 1 taken 311 times.
14346856 if(getOnSideviewLadder())
8269 {
8270
4/8
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 311 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 311 times.
311 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
8271 {
8272 setOnSideviewLadder(false);
8273 }
8274
2/8
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 311 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
311 else if(CANFORCEFACEUP)
8275 {
8276 setDir(up);
8277 }
8278 311 }
8279
8280
8/10
✓ Branch 0 taken 14291056 times.
✓ Branch 1 taken 55800 times.
✓ Branch 2 taken 14284944 times.
✓ Branch 3 taken 6112 times.
✓ Branch 4 taken 14284688 times.
✓ Branch 5 taken 256 times.
✓ Branch 6 taken 14284688 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14284688 times.
14346856 if(action!=inwind && action!=drowning && action!=lavadrowning && action!= sidedrowning && !is_autowalking())
8281 {
8282
2/2
✓ Branch 0 taken 13231508 times.
✓ Branch 1 taken 1053180 times.
14284688 if(!get_qr(qr_OLD_CHEST_COLLISION))
8283 {
8284 1053180 checkchest(cCHEST);
8285 1053180 checkchest(cLOCKEDCHEST);
8286 1053180 checkchest(cBOSSCHEST);
8287 1053180 }
8288
2/2
✓ Branch 0 taken 13717421 times.
✓ Branch 1 taken 567267 times.
14284688 if(!get_qr(qr_OLD_LOCKBLOCK_COLLISION))
8289 {
8290 567267 checkchest(cLOCKBLOCK);
8291 567267 checkchest(cBOSSLOCKBLOCK);
8292 567267 }
8293 14284688 checksigns();
8294 14284688 checkgenpush();
8295 14284688 }
8296
8297
4/4
✓ Branch 0 taken 13527418 times.
✓ Branch 1 taken 819438 times.
✓ Branch 2 taken 13524303 times.
✓ Branch 3 taken 3115 times.
14346856 if(isStanding(true) && fall == 0)
8298 {
8299
1/2
✓ Branch 0 taken 13524303 times.
✗ Branch 1 not taken.
13524303 if(extra_jump_count > 0)
8300 extra_jump_count = 0;
8301 13524303 coyotetime = 0;
8302 13524303 }
8303
2/2
✓ Branch 0 taken 51846 times.
✓ Branch 1 taken 770707 times.
822553 else if(coyotetime < 65535)
8304 {
8305 770707 ++coyotetime;
8306 770707 }
8307
2/2
✓ Branch 0 taken 14287449 times.
✓ Branch 1 taken 59407 times.
14346856 if(can_use_item(itype_hoverboots,i_hoverboots))
8308 {
8309 59407 int32_t hoverid = current_item_id(itype_hoverboots);
8310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59407 times.
59407 if(!(itemsbuf[hoverid].flags & item_flag1))
8311 {
8312
1/2
✓ Branch 0 taken 59407 times.
✗ Branch 1 not taken.
59407 if(hoverclk < 0) hoverclk = 0;
8313 59407 hoverflags &= ~HOV_OUT;
8314 59407 }
8315 59407 }
8316 14346856 bool platformfell2 = false;
8317 14346856 last_rocs_id = getRocsPressed(); // reset the cached roc's feather ID
8318
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14346856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14346856 if (current_rocs_jump_id > -1 && current_rocs_jump_id != last_rocs_id)
8319 released_jump_button = true;
8320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14346856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14346856 if (current_rocs_jump_id > -1 && released_jump_button)
8321 {
8322 itemdata const& last_rocs = itemsbuf[current_rocs_jump_id];
8323 if (fall < 0)
8324 {
8325 if (last_rocs.flags & item_flag6)
8326 {
8327 int32_t jump_loss = last_rocs.misc6 / 100;
8328 fall = zc_min(0_zf, fall + jump_loss);
8329 }
8330 if (fall >= 0)
8331 try_hover();
8332 }
8333 if (fall >= 0)
8334 {
8335 current_rocs_jump_id = -1;
8336 released_jump_button = false;
8337 }
8338 }
8339 14346856 last_grav_boots_id = -1; // clear grav boots, so that they are re-checked in get_gravity()/get_terminalv() if needed
8340 14346856 int32_t gravity3 = get_grav_fall();
8341 14346856 int32_t termv = get_terminalv();
8342 14346856 bool used_grav_or_termv = false;
8343
8344
2/2
✓ Branch 0 taken 37448 times.
✓ Branch 1 taken 14309408 times.
14346856 if (handle_termv())
8345 37448 used_grav_or_termv = true;
8346
3/4
✓ Branch 0 taken 14299022 times.
✓ Branch 1 taken 10386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14299022 times.
14309408 else if (fall > termv || fakefall > termv)
8347 {
8348
2/4
✓ Branch 0 taken 10386 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
10390 if ((last_grav_boots_id != -1) ||
8349
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 10382 times.
10386 (last_rocs_id != -1 && (itemsbuf[last_rocs_id].flags & item_flag5)))
8350 {
8351 if (fall > termv)
8352 fall = termv;
8353 if (fakefall > termv)
8354 fakefall = termv;
8355 used_grav_or_termv = true;
8356 }
8357 10386 }
8358
2/2
✓ Branch 0 taken 14027812 times.
✓ Branch 1 taken 319044 times.
14346856 bool nograv = (sideview_mode() && is_autowalking());
8359
2/2
✓ Branch 0 taken 37448 times.
✓ Branch 1 taken 14309408 times.
14346856 if(nograv)
8360 ;
8361
2/2
✓ Branch 0 taken 319044 times.
✓ Branch 1 taken 13990364 times.
14309408 else if(sideview_mode()) // Sideview gravity
8362 {
8363 //Handle falling through a platform
8364 319044 bool platformfell = false;
8365
3/4
✓ Branch 0 taken 161041 times.
✓ Branch 1 taken 158003 times.
✓ Branch 2 taken 161041 times.
✗ Branch 3 not taken.
319044 if (on_sideview_solid_oldpos(this,true,3) && !on_sideview_solid_oldpos(this,false,3))
8366 {
8367 if (!(!on_sideview_slope(Hero.x, Hero.y, Hero.old_x, Hero.old_y) && (on_sideview_slope(Hero.x, Hero.y + 1, Hero.old_x, Hero.old_y) || on_sideview_slope(Hero.x, Hero.y + 2, Hero.old_x, Hero.old_y)) && getInput(btnDown, INPUT_HERO_ACTION))) platformfell = true;
8368 y+=1; //Fall down a pixel instantly, through the platform.
8369 if(fall < 0) fall = 0;
8370 if(jumping < 0) jumping = 0;
8371 platformfell2 = true;
8372 }
8373 //Unless using old collision, run this check BEFORE moving Hero, to prevent clipping into the ceiling.
8374
2/2
✓ Branch 0 taken 313554 times.
✓ Branch 1 taken 5490 times.
319044 if(!get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
8375 {
8376
14/22
✓ Branch 0 taken 4180 times.
✓ Branch 1 taken 1310 times.
✓ Branch 2 taken 1310 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1310 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1310 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1310 times.
✓ Branch 10 taken 8 times.
✓ Branch 11 taken 1302 times.
✓ Branch 12 taken 1302 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1302 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 1302 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 1302 times.
✓ Branch 20 taken 5482 times.
✓ Branch 21 taken 8 times.
6800 if(fall < 0 && (_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,STANDING_Z_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?(fall/100):(fall/100)+8),1,STANDING_Z_STATE)
8377
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1302 times.
✓ Branch 2 taken 1302 times.
✗ Branch 3 not taken.
1302 || ((y+(fall/100)<=0) &&
8378 // Extra checks if Smart Screen Scrolling is enabled
8379 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(hero_scr->flags&fMAZE)) &&
8380 !(hero_scr->flags2&wfUP)) && (nextcombo_solid(up)))))))
8381 {
8382 8 fall = jumping = 0; // Bumped his head
8383
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8384 y -= y.getInt()%8; //fix coords
8385 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8387 {
8388 8 checkdamagecombos(x+4, x+12, y-1, y-1);
8389 8 }
8390 8 }
8391 5490 }
8392 // Fall, unless on a ladder, sideview ladder, rafting, using the hookshot, drowning, sideswimming or cheating.
8393
8/14
✗ Branch 0 not taken.
✓ Branch 1 taken 319044 times.
✓ Branch 2 taken 319044 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319044 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319044 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319044 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319044 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 311 times.
✓ Branch 13 taken 318733 times.
319044 if (!(toogam && getInput(btnUp, INPUT_HERO_ACTION)) && !drownclk && action != rafting && !IsSideSwim() && !pull_hero && !((ladderx || laddery) && fall > 0) && !getOnSideviewLadder())
8394 {
8395
1/2
✓ Branch 0 taken 318733 times.
✗ Branch 1 not taken.
318733 int32_t ydiff = fall/(spins && fall<0 ? 200:100);
8396 318733 falling_oldy = y; // Stomp Boots-related variable
8397
8398
5/8
✓ Branch 0 taken 60726 times.
✓ Branch 1 taken 258007 times.
✓ Branch 2 taken 60726 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60726 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 318733 times.
✗ Branch 7 not taken.
318733 if(fall > 0 && (checkSVLadderPlatform(x+4,y+ydiff+15)||checkSVLadderPlatform(x+12,y+ydiff+15)) && (TRUNCATE_TILE(y.getInt()+ydiff+15) != TRUNCATE_TILE(y.getInt()+15)) && !platform_fallthrough())
8399 {
8400 ydiff -= (y.getInt()+ydiff)%16;
8401 }
8402
4/4
✓ Branch 0 taken 87354 times.
✓ Branch 1 taken 231379 times.
✓ Branch 2 taken 84656 times.
✓ Branch 3 taken 2698 times.
318733 if(ydiff && !get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8403 {
8404
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 1146 times.
2698 if(ydiff > 0)
8405 {
8406
2/2
✓ Branch 0 taken 1511 times.
✓ Branch 1 taken 3277 times.
4788 for(auto q = 0; q < ydiff; ++q)
8407 {
8408
2/2
✓ Branch 0 taken 3236 times.
✓ Branch 1 taken 41 times.
3277 if(on_sideview_solid_oldpos(this, false, 0, 0, q))
8409 {
8410 41 ydiff = q;
8411 41 break;
8412 }
8413 3236 }
8414 1552 }
8415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1146 times.
1146 else if(ydiff < 0)
8416 {
8417
2/2
✓ Branch 0 taken 1146 times.
✓ Branch 1 taken 2639 times.
3785 for(auto q = 0; q > ydiff; --q)
8418 {
8419
1/2
✓ Branch 0 taken 2639 times.
✗ Branch 1 not taken.
2639 if(_walkflag(x+4,y+(bigHitbox?0:8)+q-1,1)
8420
1/2
✓ Branch 0 taken 2639 times.
✗ Branch 1 not taken.
2639 || _walkflag(x+12,y+(bigHitbox?0:8)+q,1))
8421 {
8422 ydiff = q;
8423 break;
8424 }
8425 2639 }
8426 1146 }
8427 2698 }
8428 318733 y+=ydiff;
8429 318733 hs_starty+=ydiff;
8430
8431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318733 times.
318733 for(int32_t j=0; j<chainlinks.Count(); j++)
8432 {
8433 chainlinks.spr(j)->y+=ydiff;
8434 }
8435
8436
1/2
✓ Branch 0 taken 318733 times.
✗ Branch 1 not taken.
318733 if(Lwpns.idFirst(wHookshot)>-1)
8437 {
8438 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=ydiff;
8439 }
8440
8441
1/2
✓ Branch 0 taken 318733 times.
✗ Branch 1 not taken.
318733 if(Lwpns.idFirst(wHSHandle)>-1)
8442 {
8443 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=ydiff;
8444 }
8445 318733 }
8446
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 311 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
311 else if(IsSideSwim() && action != sidewaterhold1 && action != sidewaterhold2 && action != sideswimcasting && action != sideswimfreeze)
8447 {
8448 fall = hoverclk = jumping = 0;
8449 inair = false;
8450 hoverflags = 0;
8451 if (!getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && !autostep)
8452 {
8453 WalkflagInfo info;
8454 if (game->get_watergrav()<0)
8455 {
8456 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
8457 execute(info);
8458 }
8459 else
8460 {
8461 info = walkflag(x,y+15+2,2,down);
8462 execute(info);
8463 }
8464
8465 if(!info.isUnwalkable() && (game->get_watergrav() > 0 || iswaterex_z3(MAPCOMBO(x,y+8-(bigHitbox*8)-2), -1, x, y+8-(bigHitbox*8)-2, true, false)))
8466 {
8467 y += (game->get_watergrav()/10000.0);
8468 }
8469 }
8470 }
8471 // Stop hovering/falling if you land on something.
8472 319044 bool needFall = false;
8473
6/8
✓ Branch 0 taken 157365 times.
✓ Branch 1 taken 161679 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 319044 times.
✓ Branch 4 taken 161990 times.
✓ Branch 5 taken 157054 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 161990 times.
319044 if((on_sideview_solid_oldpos(this) || getOnSideviewLadder()) && !(pull_hero && dir==down) && action!=rafting && !platformfell2)
8474 {
8475 161990 stop_item_sfx(itype_hoverboots);
8476 161990 auto oldfall = fall;
8477 161990 fall = hoverclk = jumping = 0;
8478
2/2
✓ Branch 0 taken 159688 times.
✓ Branch 1 taken 2302 times.
161990 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
8479 {
8480
4/6
✓ Branch 0 taken 159688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 156423 times.
✓ Branch 3 taken 3265 times.
✓ Branch 4 taken 156423 times.
✗ Branch 5 not taken.
159688 if(!getOnSideviewLadder() && (oldfall > 0 || get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON)))
8481 {
8482 159688 y.doFloor();
8483 159688 y-=(int32_t)y%8; //fix position
8484 159688 }
8485
2/2
✓ Branch 0 taken 3265 times.
✓ Branch 1 taken 156423 times.
159688 if(oldfall > 0)
8486 3265 land_on_ground();
8487 159688 }
8488 else
8489 {
8490 2302 snap_platform();
8491
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 2227 times.
2302 if(oldfall > 0)
8492 75 land_on_ground();
8493 }
8494 161990 inair = false;
8495 161990 hoverflags = 0;
8496
8497
4/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 161976 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
161990 if(y>=world_h-16 && cur_screen>=0x70 && !(get_scr_for_world_xy(x, y)->flags2&wfDOWN)) // Landed on the bottommost screen.
8498 14 y = world_h-16;
8499 161990 }
8500 // Stop hovering if you press down.
8501
3/6
✓ Branch 0 taken 157054 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 157054 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 157054 times.
✗ Branch 5 not taken.
157054 else if ((hoverclk > 0 || ladderx || laddery) && getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
8502 {
8503 stop_item_sfx(itype_hoverboots);
8504 hoverclk = -hoverclk;
8505 reset_ladder();
8506 fall = gravity3;
8507 used_grav_or_termv = true;
8508 inair = false;
8509 }
8510
8/10
✓ Branch 0 taken 157054 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3579 times.
✓ Branch 3 taken 153475 times.
✓ Branch 4 taken 1340 times.
✓ Branch 5 taken 2239 times.
✓ Branch 6 taken 1340 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 344 times.
✓ Branch 9 taken 996 times.
157054 else if (hoverclk < 1 && !inair && fall == 0 && !IsSideSwim() && justmoved <= 0)
8511 {
8512 996 needFall = true;
8513
2/2
✓ Branch 0 taken 867 times.
✓ Branch 1 taken 129 times.
996 if (replay_version_check(0, 23))
8514 {
8515 867 zfix my = y + 4;
8516
2/2
✓ Branch 0 taken 741 times.
✓ Branch 1 taken 2388 times.
3129 for (zfix ty = y + 1; ty < my; ++ty)
8517 {
8518
2/2
✓ Branch 0 taken 2262 times.
✓ Branch 1 taken 126 times.
2388 if (on_sideview_solid_oldpos(this, false, 0, 0, ty-y))
8519 {
8520 126 y = ty;
8521
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (check_new_slope(x, ty + 1, 16, 16, old_x, old_y, false) < 0)
8522 {
8523 if (!slopeid)
8524 slopeid = get_new_slope(x, ty + 1, 16, 16, old_x, old_y).get_info().slope();
8525 onplatid = 1;
8526 }
8527 126 needFall = false;
8528 126 break;
8529 }
8530 2262 }
8531 867 }
8532 else
8533 {
8534 129 zfix dy = 0;
8535 129 bool landed = false;
8536
3/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129 times.
✗ Branch 5 not taken.
2322 dy = binary_search_zfix(0, 4, [&](zfix val, zfix& retval)
8537 {
8538
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2077 times.
2193 if (on_sideview_solid_oldpos(this, false, 0, 0, val))
8539 {
8540 116 retval = val;
8541 116 landed = true;
8542 116 return BSEARCH_CONTINUE_TOWARD0;
8543 }
8544 2077 else return BSEARCH_CONTINUE_AWAY0;
8545 2193 });
8546
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 112 times.
129 if (dy)
8547 {
8548 112 push_move(0, dy);
8549 112 }
8550
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 112 times.
129 if (landed)
8551 {
8552
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 96 times.
112 if (check_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y, false, true) < 0)
8553 {
8554
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 16 times.
96 if (!slopeid)
8555 16 slopeid = get_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y).get_info().slope();
8556 96 onplatid = 1;
8557 96 }
8558 112 needFall = false;
8559 112 }
8560 }
8561 996 }
8562 else
8563 {
8564 156058 needFall = true;
8565 }
8566 // Continue falling.
8567
8568
4/4
✓ Branch 0 taken 309693 times.
✓ Branch 1 taken 9351 times.
✓ Branch 2 taken 162228 times.
✓ Branch 3 taken 147465 times.
319044 if(fall <= termv && needFall)
8569 {
8570 147465 inair = true;
8571
3/4
✓ Branch 0 taken 56360 times.
✓ Branch 1 taken 91105 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 56360 times.
147465 if (fall != 0 || hoverclk > 0)
8572 91105 jumping++;
8573
8574 // Bump head if: hit a solid combo from beneath, or hit a solid combo in the screen above this one.
8575
2/2
✓ Branch 0 taken 144750 times.
✓ Branch 1 taken 2715 times.
147465 if(get_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON))
8576 {
8577
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 144750 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144750 times.
✓ Branch 4 taken 144026 times.
✓ Branch 5 taken 724 times.
289500 if((_walkflag(x+4,y-(bigHitbox?9:1),0,STANDING_Z_STATE)
8578
4/4
✓ Branch 0 taken 138377 times.
✓ Branch 1 taken 6373 times.
✓ Branch 2 taken 1123 times.
✓ Branch 3 taken 137254 times.
144750 || (y<=(bigHitbox?9:1) &&
8579 // Extra checks if Smart Screen Scrolling is enabled
8580
2/6
✓ Branch 0 taken 1123 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1123 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1123 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(hero_scr->flags&fMAZE)) &&
8581 !(hero_scr->flags2&wfUP)) && (nextcombo_solid(up))))))
8582
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
6373 && fall < 0)
8583 {
8584 724 fall = jumping = 0; // Bumped his head
8585
8586 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8587
2/2
✓ Branch 0 taken 614 times.
✓ Branch 1 taken 110 times.
724 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8588 {
8589 110 checkdamagecombos(x+4, x+12, y-1, y-1);
8590 110 }
8591 724 }
8592 144750 }
8593 else
8594 {
8595
10/16
✗ Branch 0 not taken.
✓ Branch 1 taken 2715 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2715 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2715 times.
✓ Branch 6 taken 10 times.
✓ Branch 7 taken 2705 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 2705 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2705 times.
✓ Branch 12 taken 2705 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2713 times.
✓ Branch 15 taken 2 times.
5430 if((_walkflag(x+4,y+((bigHitbox||!diagonalMovement)?-1:7),1,STANDING_Z_STATE) || _walkflag(x+12,y+((bigHitbox||!diagonalMovement)?-1:7),1,STANDING_Z_STATE)
8596
2/4
✓ Branch 0 taken 2705 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2705 times.
2705 || ((y<=0) &&
8597 // Extra checks if Smart Screen Scrolling is enabled
8598 (nextcombo_wf(up) || ((get_qr(qr_SMARTSCREENSCROLL)&&(!(hero_scr->flags&fMAZE)) &&
8599 !(hero_scr->flags2&wfUP)) && (nextcombo_solid(up))))))
8600
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
10 && fall < 0)
8601 {
8602 2 fall = jumping = 0; // Bumped his head
8603 2 y -= y.getInt()%8; //fix coords
8604 // ... maybe on spikes //this is the change from 2.50.1RC3 that Saffith made, that breaks some old quests. -Z
8605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( !get_qr(qr_OLDSIDEVIEWSPIKES) ) //fix for older sideview quests -Z
8606 {
8607 2 checkdamagecombos(x+4, x+12, y-1, y-1);
8608 2 }
8609 2 }
8610 }
8611
8612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147465 times.
147465 if(hoverclk > 0)
8613 {
8614 if(tick_hover() && !ladderx && !laddery)
8615 {
8616 fall += gravity3;
8617 used_grav_or_termv = true;
8618 }
8619 }
8620
3/4
✓ Branch 0 taken 105265 times.
✓ Branch 1 taken 42200 times.
✓ Branch 2 taken 57230 times.
✗ Branch 3 not taken.
147465 else if(fall+gravity3 > 0 && fall<=0
8621
2/2
✓ Branch 0 taken 57230 times.
✓ Branch 1 taken 48035 times.
105265 && try_hover())
8622 used_grav_or_termv = true;
8623
4/8
✓ Branch 0 taken 147465 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147465 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147465 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 147465 times.
147465 else if(!ladderx && !laddery && !getOnSideviewLadder() && !IsSideSwim())
8624 {
8625 147465 fall += gravity3;
8626 147465 used_grav_or_termv = true;
8627 147465 }
8628 147465 }
8629
2/2
✓ Branch 0 taken 162228 times.
✓ Branch 1 taken 9351 times.
171579 else if(needFall)
8630 {
8631
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9351 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9351 if (get_qr(qr_BETTER_PLAYER_JUMP_ANIM) && (fall != 0 || hoverclk > 0))
8632 jumping++;
8633 9351 used_grav_or_termv = true;
8634 9351 }
8635 319044 }
8636 else // Topdown gravity
8637 {
8638
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13990364 times.
✓ Branch 2 taken 13986906 times.
✓ Branch 3 taken 3458 times.
13990364 if (!(moveflags & move_no_fake_z)) fakez-=fakefall/(spins && fakefall>0 ? 200:100);
8639
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13990364 times.
✓ Branch 2 taken 13986906 times.
✓ Branch 3 taken 3458 times.
13990364 if (!(moveflags & move_no_real_z)) z-=fall/(spins && fall>0 ? 200:100);
8640
3/4
✓ Branch 0 taken 13971258 times.
✓ Branch 1 taken 19106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13971258 times.
13990364 if(z>0||fakez>0)
8641 {
8642
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 19106 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
19106 switch(action)
8643 {
8644 case swimming:
8645 {
8646 diveclk=0;
8647 action=walking; FFCore.setHeroAction(walking);
8648
8649 break;
8650 }
8651 case waterhold1:
8652 {
8653 action=landhold1; FFCore.setHeroAction(landhold1);
8654 break;
8655 }
8656
8657 case waterhold2:
8658 {
8659 action=landhold2; FFCore.setHeroAction(landhold2);
8660 break;
8661 }
8662
8663 default:
8664 19106 break;
8665 }
8666 19106 }
8667
8668
2/2
✓ Branch 0 taken 160887 times.
✓ Branch 1 taken 13990364 times.
14151251 for(int32_t j=0; j<chainlinks.Count(); j++)
8669 {
8670 160887 chainlinks.spr(j)->z=z;
8671 160887 chainlinks.spr(j)->fakez=fakez;
8672 160887 }
8673
8674
2/2
✓ Branch 0 taken 44964 times.
✓ Branch 1 taken 13945400 times.
13990364 if(Lwpns.idFirst(wHookshot)>-1)
8675 {
8676 44964 Lwpns.spr(Lwpns.idFirst(wHookshot))->z=z;
8677 44964 Lwpns.spr(Lwpns.idFirst(wHookshot))->fakez=fakez;
8678 44964 }
8679
8680
2/2
✓ Branch 0 taken 47398 times.
✓ Branch 1 taken 13942966 times.
13990364 if(Lwpns.idFirst(wHSHandle)>-1)
8681 {
8682 47398 Lwpns.spr(Lwpns.idFirst(wHSHandle))->z=z;
8683 47398 Lwpns.spr(Lwpns.idFirst(wHSHandle))->fakez=fakez;
8684 47398 }
8685
8686
3/4
✓ Branch 0 taken 13971258 times.
✓ Branch 1 taken 19106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13971258 times.
13990364 if(z<=0&&!(moveflags & move_no_real_z))
8687 {
8688 13971258 auto oldfall = fall;
8689 13971258 z = fall = 0;
8690
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13971258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13971258 if (fakez <= 0 || (moveflags & move_no_fake_z))
8691 {
8692
2/2
✓ Branch 0 taken 13970821 times.
✓ Branch 1 taken 437 times.
13971258 if(oldfall > 0)
8693 {
8694 437 land_on_ground();
8695
8696 437 stomping = true;
8697 437 }
8698 13971258 }
8699
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13971258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13971258 if (fakez <= 0 || (moveflags & move_no_fake_z))
8700 {
8701 13971258 jumping = 0;
8702
2/2
✓ Branch 0 taken 3926 times.
✓ Branch 1 taken 13967332 times.
13971258 if(check_pitslide(true) == -1)
8703 {
8704 13967332 hoverclk = 0;
8705 13967332 hoverflags = 0;
8706 13967332 }
8707 3926 else tick_hover();
8708 13971258 }
8709 13971258 }
8710
2/4
✓ Branch 0 taken 19106 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19106 times.
✗ Branch 3 not taken.
19106 else if(fakez<=0&&!(moveflags & move_no_fake_z))
8711 {
8712 19106 auto oldfakefall = fakefall;
8713 19106 fakez = fakefall = 0;
8714
2/4
✓ Branch 0 taken 19106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19106 times.
19106 if (z <= 0 || (moveflags & move_no_real_z))
8715 {
8716 if(oldfakefall > 0)
8717 {
8718 land_on_ground();
8719
8720 stomping = true;
8721 }
8722 }
8723
2/4
✓ Branch 0 taken 19106 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19106 times.
19106 if (z <= 0 || (moveflags & move_no_real_z))
8724 {
8725 jumping = 0;
8726 if(check_pitslide(true) == -1)
8727 {
8728 hoverclk = 0;
8729 hoverflags = 0;
8730 }
8731 else tick_hover();
8732 }
8733 19106 }
8734
8/10
✓ Branch 0 taken 13989982 times.
✓ Branch 1 taken 382 times.
✓ Branch 2 taken 13989982 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13952916 times.
✓ Branch 5 taken 37066 times.
✓ Branch 6 taken 13971640 times.
✓ Branch 7 taken 13934192 times.
✓ Branch 8 taken 13971640 times.
✗ Branch 9 not taken.
13990364 if(fall <= termv && !(moveflags & move_no_real_z) && z>0 || fakefall <= termv && !(moveflags & move_no_fake_z) && fakez > 0)
8735 {
8736
4/6
✓ Branch 0 taken 3050 times.
✓ Branch 1 taken 15674 times.
✓ Branch 2 taken 3050 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3050 times.
27924556 if(fall != 0 || fakefall != 0 || hoverclk>0)
8737 15674 jumping++;
8738
8739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18724 times.
18724 if(hoverclk > 0)
8740 {
8741 if(tick_hover())
8742 {
8743 if (!(moveflags & move_no_real_z) && z > 0)
8744 {
8745 if (fall <= termv) fall += gravity3;
8746 used_grav_or_termv = true;
8747 }
8748 if (!(moveflags & move_no_fake_z) && fakez > 0)
8749 {
8750 if (fakefall <= termv) fakefall += gravity3;
8751 used_grav_or_termv = true;
8752 }
8753 }
8754 }
8755
9/14
✓ Branch 0 taken 10894 times.
✓ Branch 1 taken 7830 times.
✓ Branch 2 taken 3135 times.
✓ Branch 3 taken 7759 times.
✓ Branch 4 taken 3135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 18724 times.
✗ Branch 13 not taken.
18724 else if (((fall + gravity3 > 0 && fall <= 0 && !(moveflags & move_no_real_z) && z > 0) || (fakefall + gravity3 > 0 && fakefall <= 0 && !(moveflags & move_no_fake_z) && fakez > 0))
8756 18724 && try_hover())
8757 used_grav_or_termv = true;
8758 else
8759 {
8760
2/4
✓ Branch 0 taken 18724 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18724 times.
18724 if (!(moveflags & move_no_real_z) && z > 0)
8761 {
8762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18724 times.
18724 if (fall <= termv) fall += gravity3;
8763 18724 used_grav_or_termv = true;
8764 18724 }
8765
2/4
✓ Branch 0 taken 18724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18724 times.
✗ Branch 3 not taken.
18724 if (!(moveflags & move_no_fake_z) && fakez > 0)
8766 {
8767 if (fakefall <= termv) fakefall += gravity3;
8768 used_grav_or_termv = true;
8769 }
8770 }
8771 18724 }
8772
5/10
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 13952503 times.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 13952503 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
13952916 if(fall > termv && !(moveflags & move_no_real_z) && z>0 || fakefall > termv && !(moveflags & move_no_fake_z) && fakez > 0)
8773 {
8774
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
413 if (get_qr(qr_BETTER_PLAYER_JUMP_ANIM) && (fall != 0 || fakefall != 0 || hoverclk > 0))
8775 jumping++;
8776 413 used_grav_or_termv = true;
8777 413 }
8778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13952916 times.
13952916 if (fakez<0) fakez = 0;
8779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13952916 times.
13952916 if (z<0) z = 0;
8780 }
8781
8782
1/2
✓ Branch 0 taken 14309408 times.
✗ Branch 1 not taken.
14309408 if (handle_termv())
8783 used_grav_or_termv = true;
8784
8785
3/4
✓ Branch 0 taken 175922 times.
✓ Branch 1 taken 14133486 times.
✓ Branch 2 taken 175922 times.
✗ Branch 3 not taken.
14309408 if (used_grav_or_termv && last_grav_boots_id > -1) // if the gravity boots affected the player's falling, charge their cost
8786 paymagiccost(last_grav_boots_id);
8787
8788
2/2
✓ Branch 0 taken 3663208448 times.
✓ Branch 1 taken 14309408 times.
3677517856 for (int q = 0; q < MAXITEMS; ++q)
8789
1/2
✓ Branch 0 taken 3663208448 times.
✗ Branch 1 not taken.
3663208448 if (item_cooldown[q] > 0)
8790 --item_cooldown[q];
8791
8792
2/2
✓ Branch 0 taken 14308660 times.
✓ Branch 1 taken 748 times.
14309408 if(drunkclk)
8793 {
8794 748 --drunkclk;
8795 748 }
8796
8797
2/2
✓ Branch 0 taken 14308719 times.
✓ Branch 1 taken 689 times.
14309408 if(lstunclock > 0)
8798 {
8799 // also cancel Hero's attack
8800 689 attackclk = 0;
8801
8802
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 261 times.
689 if( FFCore.getHeroAction() != stunned )
8803 {
8804 261 tempaction=action; //update so future checks won't do this
8805 //action=freeze; //setting this makes the player invincible while stunned -V
8806 261 FFCore.setHeroAction(stunned);
8807 261 }
8808 689 --lstunclock;
8809 689 }
8810 //if the stun action is still set in FFCore, but he isn't stunned, then the timer reached 0
8811 //, so we unfreeze him here, and return him to the action that he had when he was stunned.
8812
4/4
✓ Branch 0 taken 689 times.
✓ Branch 1 taken 14308719 times.
✓ Branch 2 taken 655 times.
✓ Branch 3 taken 34 times.
14309408 if ( FFCore.getHeroAction() == stunned && !lstunclock )
8813 {
8814 34 action=tempaction; FFCore.setHeroAction(tempaction);
8815 34 }
8816
8817
1/2
✓ Branch 0 taken 14309408 times.
✗ Branch 1 not taken.
14309408 if( lbunnyclock > 0 )
8818 {
8819 --lbunnyclock;
8820 }
8821
2/2
✓ Branch 0 taken 1925 times.
✓ Branch 1 taken 14307483 times.
14309408 if(DMaps[cur_dmap].flags&dmfBUNNYIFNOPEARL)
8822 {
8823 1925 int32_t itemid = current_item_id(itype_pearl);
8824
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 1802 times.
1925 if(itemid > -1)
8825 {
8826
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 122 times.
123 if(lbunnyclock == -1) //cure dmap-caused bunny effect
8827 1 lbunnyclock = 0;
8828 123 }
8829
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1801 times.
1802 else if(lbunnyclock > -1) //No pearl, force into bunny mode
8830 {
8831 1 lbunnyclock = -1;
8832 1 }
8833 1925 }
8834
1/2
✓ Branch 0 taken 14307483 times.
✗ Branch 1 not taken.
14307483 else if(lbunnyclock == -1) //dmap-caused bunny effect
8835 {
8836 lbunnyclock = 0;
8837 }
8838
8839
7/20
✗ Branch 0 not taken.
✓ Branch 1 taken 14309408 times.
✓ Branch 2 taken 14309408 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14309408 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14309408 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 14309408 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14309408 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 14309408 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
28618816 bool is_broken_behavior = replay_is_active() && replay_get_meta_str("sav") == "link_to_the_zelda_2_of_3.sav";
8840
5/6
✓ Branch 0 taken 174158 times.
✓ Branch 1 taken 14135250 times.
✓ Branch 2 taken 18776 times.
✓ Branch 3 taken 155382 times.
✓ Branch 4 taken 14154026 times.
✗ Branch 5 not taken.
28463434 bool fall_check = (fall == 0 || z > 0) && (fakefall == 0 || fakez > 0);
8841
2/2
✓ Branch 0 taken 13992615 times.
✓ Branch 1 taken 316793 times.
14309408 if (is_broken_behavior)
8842
5/6
✓ Branch 0 taken 1196 times.
✓ Branch 1 taken 315597 times.
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 1040 times.
✓ Branch 4 taken 1040 times.
✗ Branch 5 not taken.
316793 fall_check = (fall == 0 || z > 0) || (fakefall == 0 || fakez > 0);
8843
8844
11/14
✓ Branch 0 taken 14254467 times.
✓ Branch 1 taken 54941 times.
✓ Branch 2 taken 9705831 times.
✓ Branch 3 taken 4548636 times.
✓ Branch 4 taken 9705831 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9705831 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9705821 times.
✓ Branch 9 taken 10 times.
✓ Branch 10 taken 9704012 times.
✓ Branch 11 taken 1809 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 9624720 times.
23934128 if(!is_on_conveyor && !(diagonalMovement||NO_GRIDLOCK) && fall_check && charging==0 && spins<=5
8845
4/4
✓ Branch 0 taken 9703418 times.
✓ Branch 1 taken 594 times.
✓ Branch 2 taken 9624720 times.
✓ Branch 3 taken 78698 times.
9704012 && action != gothit && !is_autowalking())
8846 {
8847
2/3
✓ Branch 0 taken 4350755 times.
✓ Branch 1 taken 5273965 times.
✗ Branch 2 not taken.
9624720 switch(dir)
8848 {
8849 case up:
8850 case down:
8851 4350755 x = TRUNCATE_HALF_TILE(x.getInt() + 4);
8852 4350755 break;
8853
8854 case left:
8855 case right:
8856 5273965 y = TRUNCATE_HALF_TILE(y.getInt() + 4);
8857 5273965 break;
8858 }
8859 9624720 }
8860
8861
4/4
✓ Branch 0 taken 137817 times.
✓ Branch 1 taken 14171591 times.
✓ Branch 2 taken 52294 times.
✓ Branch 3 taken 85523 times.
14309408 if((watch==true) && clockclk)
8862 {
8863 52294 --clockclk;
8864
8865
2/2
✓ Branch 0 taken 52151 times.
✓ Branch 1 taken 143 times.
52294 if(!clockclk)
8866 {
8867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(cheat_superman==false)
8868 {
8869 143 setClock(false);
8870 143 }
8871
8872 143 watch=false;
8873
8874
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 143 times.
150 for (auto it : clock_zoras)
8875 {
8876 7 int screen = it.first;
8877 7 int id = it.second;
8878 7 addenemy(screen,0,0,id,0);
8879 }
8880 143 }
8881 52294 }
8882
8883
4/4
✓ Branch 0 taken 14262010 times.
✓ Branch 1 taken 47398 times.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 14253306 times.
14309408 if(hookshot_frozen || switch_hooked)
8884 {
8885
4/4
✓ Branch 0 taken 11138 times.
✓ Branch 1 taken 44964 times.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 2434 times.
56102 if(hookshot_used || switch_hooked)
8886 {
8887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53668 times.
53668 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
8888 53668 else {action=freeze; FFCore.setHeroAction(freeze);} //could be LA_HOOKSHOT for FFCore. -Z
8889
8890
3/4
✓ Branch 0 taken 36319 times.
✓ Branch 1 taken 17349 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36319 times.
53668 if(pull_hero || switch_hooked)
8891 {
8892
3/4
✓ Branch 0 taken 8585 times.
✓ Branch 1 taken 8764 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8585 times.
17349 if(hs_switcher || switch_hooked)
8893 {
8894 8764 hs_fix = false;
8895
1/2
✓ Branch 0 taken 8764 times.
✗ Branch 1 not taken.
8764 if(switchhookclk)
8896 {
8897 8764 --switchhookclk;
8898
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 8627 times.
8764 if(switchhookclk==switchhookmaxtime/2) //Perform swaps
8899 {
8900
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 137 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
137 if(switchhook_cost_item > -1 && !checkmagiccost(switchhook_cost_item))
8901 reset_hookshot();
8902 else
8903 {
8904 137 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
8905 137 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
8906
8907
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 132 times.
137 if(hooked_comborpos != rpos_t::None) //Switching combos
8908 {
8909 132 rpos_t targrpos = hooked_comborpos, plrpos = COMBOPOS_REGION_B(x+8,y+8);
8910
3/6
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
132 if (hooked_layerbits && is_valid_rpos(targrpos) && is_valid_rpos(plrpos))
8911 {
8912
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
8913
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(int q = max_layer; q > -1; --q)
8914 {
8915
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 792 times.
924 if(!(hooked_layerbits & (1<<q)))
8916 792 continue; //non-switching layer
8917
8918 132 auto target_rpos_handle = get_rpos_handle(targrpos, q);
8919 132 auto player_rpos_handle = get_rpos_handle(plrpos, q);
8920
8921 132 mapscr* target_scr = target_rpos_handle.scr;
8922
8923 132 auto& cmb = target_rpos_handle.combo();
8924 132 int32_t srcfl = target_rpos_handle.sflag();
8925 132 auto& cmb2 = player_rpos_handle.combo();
8926 132 int32_t c = player_rpos_handle.data(),
8927 132 cs = player_rpos_handle.cset(),
8928 132 fl = player_rpos_handle.sflag();
8929 //{Check push status
8930 132 bool isFakePush = false;
8931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.type == cSWITCHHOOK)
8932 {
8933
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag7) //counts as 'pushblock'
8934 isFakePush = true;
8935 132 }
8936 132 bool isPush = isFakePush;
8937
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(srcfl)
8938 {
8939 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8940 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8941 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8942 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8943 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8944 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8945 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8946 isPush = true;
8947 132 }
8948
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(cmb.flag)
8949 {
8950 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
8951 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
8952 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
8953 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
8954 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
8955 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
8956 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
8957 isPush = true;
8958 132 }
8959
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(srcfl==mfPUSHED) isPush = false;
8960 //}
8961
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.type == cSWITCHHOOK) //custom flags and such
8962 {
8963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.usrflags&cflag3) //Breaks on swap
8964 {
8965 int32_t it = -1;
8966 int32_t thedropset = -1;
8967 if(cmb.usrflags&cflag4) //drop item
8968 {
8969 if(cmb.usrflags&cflag5)
8970 it = cmb.attribytes[2];
8971 else
8972 {
8973 it = select_dropitem(cmb.attribytes[2]);
8974 thedropset = cmb.attribytes[2];
8975 }
8976 }
8977
8978 breakable* br = new breakable(x, y, 0_zf,
8979 cmb, target_rpos_handle.cset(), it, thedropset, cmb.attribytes[2],
8980 cmb.attribytes[1] ? -1 : 0, cmb.attribytes[1], switchhookclk);
8981 br->switch_hooked = true;
8982 decorations.add(br);
8983 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
8984 hooked_undercombos[q] = -1;
8985
8986 if(cmb.usrflags&cflag6)
8987 {
8988 target_rpos_handle.increment_data();
8989 }
8990 else
8991 {
8992 target_rpos_handle.set_data(target_scr->undercombo);
8993 target_rpos_handle.set_cset(target_scr->undercset);
8994 if(cmb.usrflags&cflag2)
8995 target_rpos_handle.set_sflag(0);
8996 }
8997 }
8998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 else if(isPush)
8999 {
9000 //Simulate a block clicking into place
9001 movingblock mtemp;
9002 mtemp.clear();
9003
9004 auto [mx, my] = COMBOXY_REGION(plrpos);
9005
9006 mtemp.set(mx,my,target_rpos_handle.data(),target_rpos_handle.cset(),q,target_rpos_handle.sflag());
9007 mtemp.dir = getPushDir(target_rpos_handle.sflag());
9008 if(mtemp.dir < 0)
9009 mtemp.dir = getPushDir(cmb.flag);
9010 mtemp.clk = 1;
9011 mtemp.force_many = isFakePush;
9012 mtemp.no_icy = true;
9013 mtemp.animate(0);
9014 if((mtemp.bhole || mtemp.trigger)
9015 && (fl == mfBLOCKTRIGGER || fl == mfBLOCKHOLE
9016 || cmb2.flag == mfBLOCKTRIGGER
9017 || cmb2.flag == mfBLOCKHOLE))
9018 {
9019 target_rpos_handle.set_data(target_scr->undercombo);
9020 target_rpos_handle.set_cset(target_scr->undercset);
9021 target_rpos_handle.set_sflag(0);
9022 }
9023 else
9024 {
9025 target_rpos_handle.set_data(c);
9026 target_rpos_handle.set_cset(cs);
9027 if(cmb.usrflags&cflag2)
9028 target_rpos_handle.set_sflag(fl);
9029 else
9030 target_rpos_handle.set_sflag(0);
9031 }
9032 }
9033 else
9034 {
9035 132 player_rpos_handle.set_data(target_rpos_handle.data());
9036 132 player_rpos_handle.set_cset(target_rpos_handle.cset());
9037
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag2)
9038 player_rpos_handle.set_sflag(target_rpos_handle.sflag());
9039
9040 132 target_rpos_handle.set_data(c);
9041 132 target_rpos_handle.set_cset(cs);
9042
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag2)
9043 target_rpos_handle.set_sflag(fl);
9044 }
9045 132 }
9046 else if(isCuttableType(cmb.type)) //Break and drop effects
9047 {
9048 int32_t breakcs = target_rpos_handle.cset();
9049 if(isCuttableNextType(cmb.type)) //next instead of undercmb
9050 {
9051 target_rpos_handle.increment_data();
9052 }
9053 else
9054 {
9055 target_rpos_handle.set_data(target_scr->undercombo);
9056 target_rpos_handle.set_cset(target_scr->undercset);
9057 target_rpos_handle.set_sflag(0);
9058 }
9059
9060 int32_t it = -1;
9061 int32_t thedropset = -1;
9062 if(isCuttableItemType(cmb.type)) //Drop an item
9063 {
9064 if ( (cmb.usrflags&cflag2) )
9065 {
9066 if(cmb.usrflags&cflag11)
9067 it = cmb.attribytes[1];
9068 else
9069 {
9070 it = select_dropitem(cmb.attribytes[1]);
9071 thedropset = cmb.attribytes[1];
9072 }
9073 }
9074 else
9075 {
9076 it = select_dropitem(12);
9077 thedropset = 12;
9078 }
9079 }
9080
9081 byte breaksfx = 0;
9082 if(get_qr(qr_MORESOUNDS)) //SFX
9083 {
9084 if (cmb.usrflags&cflag3)
9085 {
9086 breaksfx = cmb.attribytes[2];
9087 }
9088 else if(isBushType(cmb.type)
9089 || isFlowersType(cmb.type)
9090 || isGrassType(cmb.type))
9091 {
9092 breaksfx = QMisc.miscsfx[sfxBUSHGRASS];
9093 }
9094 }
9095
9096 //Clipping sprite
9097 int16_t decotype = (cmb.usrflags & cflag1) ?
9098 ((cmb.usrflags & cflag10)
9099 ? (cmb.attribytes[0])
9100 : (-1))
9101 : (0);
9102 if(decotype > 3) decotype = 0;
9103 if(!decotype)
9104 decotype = (isBushType(cmb.type) ? 1
9105 : (isFlowersType(cmb.type) ? 2
9106 : (isGrassType(cmb.type) ? 3
9107 : ((cmb.usrflags & cflag1) ? -1
9108 : -2))));
9109
9110 breakable* br = new breakable(x, y, 0_zf,
9111 cmb, breakcs, it, thedropset, breaksfx,
9112 decotype, cmb.attribytes[0], switchhookclk);
9113 br->switch_hooked = true;
9114 decorations.add(br);
9115 hooked_layerbits &= ~(0x101<<q); //this swap completed entirely
9116 hooked_undercombos[q] = -1;
9117 }
9118 else //Unknown type, just swap combos.
9119 {
9120 if(isPush)
9121 {
9122 //Simulate a block clicking into place
9123 movingblock mtemp;
9124 mtemp.clear();
9125
9126 auto [mx, my] = COMBOXY_REGION(plrpos);
9127
9128 mtemp.set(mx,my,target_rpos_handle.data(),target_rpos_handle.cset(),q,target_rpos_handle.sflag());
9129 mtemp.dir = getPushDir(target_rpos_handle.sflag());
9130 if(mtemp.dir < 0)
9131 mtemp.dir = getPushDir(cmb.flag);
9132 mtemp.clk = 1;
9133 mtemp.animate(0);
9134 if(mtemp.bhole || mtemp.trigger)
9135 {
9136 target_rpos_handle.set_data(target_scr->undercombo);
9137 target_rpos_handle.set_cset(target_scr->undercset);
9138 target_rpos_handle.set_sflag(0);
9139 }
9140 else
9141 {
9142 target_rpos_handle.set_data(c);
9143 target_rpos_handle.set_cset(cs);
9144 target_rpos_handle.set_sflag(0);
9145 }
9146 }
9147 else
9148 {
9149 player_rpos_handle.set_data(target_rpos_handle.data());
9150 player_rpos_handle.set_cset(target_rpos_handle.cset());
9151 target_rpos_handle.set_data(c);
9152 target_rpos_handle.set_cset(cs);
9153 }
9154 }
9155 132 }
9156
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(switchhook_cost_item > -1)
9157 paymagiccost(switchhook_cost_item);
9158 132 zfix tx = x, ty = y;
9159
9160 //Position the player at the combo
9161 132 std::tie(x, y) = COMBOXY_REGION(targrpos);
9162
9163 132 dir = oppositeDir[dir];
9164
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if(w && hw)
9165 {
9166 //Calculate chain shift
9167 zfix dx = (x-tx);
9168 zfix dy = (y-ty);
9169 if(w->dir < 4)
9170 {
9171 if(w->dir & 2)
9172 dx = 0;
9173 else dy = 0;
9174 }
9175 //Position the hook head at the handle
9176 w->x = hw->x + dx;
9177 w->y = hw->y + dy;
9178 w->dir = oppositeDir[w->dir];
9179 w->doAutoRotate(true);
9180 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
9181 w->flip ^= hflip;
9182 //Position the handle appropriately
9183 hw->x = x-(hw->x-tx);
9184 hw->y = y-(hw->y-ty);
9185 hw->dir = oppositeDir[hw->dir];
9186 hw->doAutoRotate(true);
9187 hw->flip ^= hflip;
9188 //Move chains
9189 for(int32_t j=0; j<chainlinks.Count(); j++)
9190 {
9191 chainlinks.spr(j)->x += dx;
9192 chainlinks.spr(j)->y += dy;
9193 }
9194 }
9195 132 hooked_comborpos = plrpos; //flip positions
9196 132 }
9197 else reset_hookshot();
9198 132 }
9199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 else if(switching_object) //Switching an object
9200 {
9201
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(switchhook_cost_item > -1)
9202 paymagiccost(switchhook_cost_item);
9203 5 zfix tx = x, ty = y;
9204 //Position the player at the object
9205 5 x = switching_object->x;
9206 5 y = switching_object->y;
9207 5 dir = oppositeDir[dir];
9208 //Position the object at the player
9209 5 switching_object->x = tx;
9210 5 switching_object->y = ty;
9211
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
5 if(switching_object->dir == dir || switching_object->dir == oppositeDir[dir])
9212 2 switching_object->dir = oppositeDir[switching_object->dir];
9213 5 solid_update(false);
9214 5 switching_object->solid_update(false);
9215
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(item* it = dynamic_cast<item*>(switching_object))
9216 {
9217 if(itemsbuf[it->id].type == itype_fairy && itemsbuf[it->id].misc3)
9218 {
9219 movefairynew2(it->x, it->y, *it);
9220 }
9221 }
9222
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
5 if(w && hw) //!TODO No fucking clue if diagonals work
9223 {
9224 //Calculate chain shift
9225 1 zfix dx = (x-tx);
9226 1 zfix dy = (y-ty);
9227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(w->dir < 4)
9228 {
9229
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->dir & 2)
9230 1 dx = 0;
9231 else dy = 0;
9232 1 }
9233 //Position the hook head at the handle
9234 1 w->x = hw->x + dx;
9235 1 w->y = hw->y + dy;
9236 1 w->dir = oppositeDir[w->dir];
9237 1 w->doAutoRotate(true);
9238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 byte hflip = (w->dir > 3 ? 3 : ((w->dir & 2) ? 1 : 2));
9239 1 w->flip ^= hflip;
9240 1 w->solid_update(false);
9241 //Position the handle appropriately
9242 1 hw->x = x-(hw->x-tx);
9243 1 hw->y = y-(hw->y-ty);
9244 1 hw->dir = oppositeDir[hw->dir];
9245 1 hw->doAutoRotate(true);
9246 1 hw->flip ^= hflip;
9247 1 hw->solid_update(false);
9248 //Move chains
9249
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
6 for(int32_t j=0; j<chainlinks.Count(); j++)
9250 {
9251 5 chainlinks.spr(j)->x += dx;
9252 5 chainlinks.spr(j)->y += dy;
9253 5 }
9254 1 }
9255 5 }
9256 }
9257 137 }
9258
2/2
✓ Branch 0 taken 8490 times.
✓ Branch 1 taken 137 times.
8627 else if(!switchhookclk)
9259 {
9260 137 reset_hookshot();
9261 137 }
9262 8764 }
9263 else reset_hookshot();
9264 8764 }
9265 else
9266 {
9267 sprite *t;
9268 int32_t i;
9269
9270
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8761 times.
✓ Branch 2 taken 176 times.
✓ Branch 3 taken 8585 times.
8761 for(i=0; i<Lwpns.Count() && (Lwpns.spr(i)->id!=wHSHandle); i++)
9271 {
9272 /* do nothing */
9273 176 }
9274
9275 8585 t = Lwpns.spr(i);
9276
9277
2/2
✓ Branch 0 taken 17399 times.
✓ Branch 1 taken 8585 times.
25984 for(i=0; i<Lwpns.Count(); i++)
9278 {
9279 17399 sprite *s = Lwpns.spr(i);
9280
9281
2/2
✓ Branch 0 taken 8814 times.
✓ Branch 1 taken 8585 times.
17399 if(s->id==wHookshot)
9282 {
9283
2/2
✓ Branch 0 taken 2098 times.
✓ Branch 1 taken 6487 times.
8585 if (abs((s->y) - y) >= 1)
9284 {
9285
2/2
✓ Branch 0 taken 1219 times.
✓ Branch 1 taken 879 times.
2098 if((s->y)>y)
9286 {
9287 879 y+=4;
9288
9289
1/2
✓ Branch 0 taken 879 times.
✗ Branch 1 not taken.
879 if(Lwpns.idFirst(wHSHandle)!=-1)
9290 {
9291 879 t->y+=4;
9292 879 }
9293
9294 879 hs_starty+=4;
9295 879 }
9296
9297
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 1219 times.
2098 if((s->y)<y)
9298 {
9299 1219 y-=4;
9300
9301
1/2
✓ Branch 0 taken 1219 times.
✗ Branch 1 not taken.
1219 if(Lwpns.idFirst(wHSHandle)!=-1)
9302 {
9303 1219 t->y-=4;
9304 1219 }
9305
9306 1219 hs_starty-=4;
9307 1219 }
9308 2098 }
9309 else
9310 {
9311 6487 y = (s->y);
9312 }
9313
2/2
✓ Branch 0 taken 6487 times.
✓ Branch 1 taken 2098 times.
8585 if (abs((s->x) - x) >= 1)
9314 {
9315
2/2
✓ Branch 0 taken 3152 times.
✓ Branch 1 taken 3335 times.
6487 if((s->x)>x)
9316 {
9317 3335 x+=4;
9318
9319
1/2
✓ Branch 0 taken 3335 times.
✗ Branch 1 not taken.
3335 if(Lwpns.idFirst(wHSHandle)!=-1)
9320 {
9321 3335 t->x+=4;
9322 3335 }
9323
9324 3335 hs_startx+=4;
9325 3335 }
9326
9327
2/2
✓ Branch 0 taken 3335 times.
✓ Branch 1 taken 3152 times.
6487 if((s->x)<x)
9328 {
9329 3152 x-=4;
9330
9331
1/2
✓ Branch 0 taken 3152 times.
✗ Branch 1 not taken.
3152 if(Lwpns.idFirst(wHSHandle)!=-1)
9332 {
9333 3152 t->x-=4;
9334 3152 }
9335
9336 3152 hs_startx-=4;
9337 3152 }
9338 6487 }
9339 else
9340 {
9341 2098 x = (s->x);
9342 }
9343 8585 }
9344 17399 }
9345 }
9346 17349 }
9347 53668 }
9348 else
9349 {
9350 2434 Lwpns.del(Lwpns.idFirst(wHSHandle));
9351 2434 reset_hookshot();
9352 }
9353
9354
1/2
✓ Branch 0 taken 56102 times.
✗ Branch 1 not taken.
56102 if(hs_fix)
9355 {
9356 if(dir==up || dir==down)
9357 {
9358 y = TRUNCATE_TILE(int32_t(y+7));
9359 }
9360
9361 if(dir==left || dir==right)
9362 {
9363 x = TRUNCATE_TILE(int32_t(x+7));
9364 }
9365
9366 hs_fix=false;
9367 }
9368
9369 56102 }
9370
9371
2/2
✓ Branch 0 taken 1338192 times.
✓ Branch 1 taken 12971216 times.
14309408 if (!get_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP))
9372 {
9373
2/2
✓ Branch 0 taken 5312 times.
✓ Branch 1 taken 12965904 times.
12971216 if (getInput(btnL, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
9374 5312 selectNextBWpn(SEL_LEFT);
9375
2/2
✓ Branch 0 taken 12958429 times.
✓ Branch 1 taken 7475 times.
12965904 else if (getInput(btnR, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
9376 7475 selectNextBWpn(SEL_RIGHT);
9377 12971216 }
9378
4/4
✓ Branch 0 taken 1026145 times.
✓ Branch 1 taken 13283263 times.
✓ Branch 2 taken 1015490 times.
✓ Branch 3 taken 10655 times.
14309408 if (get_qr(qr_SELECTAWPN) && get_qr(qr_USE_EX1_EX2_INVENTORYSWAP))
9379 {
9380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10655 times.
10655 if (getInput(btnEx3, INPUT_PRESS | INPUT_HERO_ACTION))
9381 selectNextAWpn(SEL_LEFT);
9382
2/2
✓ Branch 0 taken 10654 times.
✓ Branch 1 taken 1 times.
10655 else if (getInput(btnEx4, INPUT_PRESS | INPUT_HERO_ACTION))
9383 1 selectNextAWpn(SEL_RIGHT);
9384 10655 }
9385
9386
2/2
✓ Branch 0 taken 14308330 times.
✓ Branch 1 taken 1078 times.
14309408 if (getInput(btnP, INPUT_PRESS | INPUT_HERO_ACTION))
9387 {
9388
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1075 times.
1078 if( !FFCore.runOnMapScriptEngine() ) //OnMap script replaces the 'onViewMap()' call
9389 1075 onViewMap();
9390 1078 }
9391
2/2
✓ Branch 0 taken 5057706 times.
✓ Branch 1 taken 14309408 times.
19367114 for(int32_t i=0; i<Lwpns.Count(); i++)
9392 {
9393 5057706 weapon *w = ((weapon*)Lwpns.spr(i));
9394
9395
6/6
✓ Branch 0 taken 5005462 times.
✓ Branch 1 taken 52244 times.
✓ Branch 2 taken 4542324 times.
✓ Branch 3 taken 463138 times.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 4542251 times.
5057706 if(w->id == wArrow || w->id == wBrang || w->id == wCByrna)
9396 515455 addsparkle(i);
9397 5057706 }
9398
9399
2/2
✓ Branch 0 taken 14308173 times.
✓ Branch 1 taken 1235 times.
14309408 if(Lwpns.idCount(wPhantom))
9400 {
9401 1235 addsparkle2(pDIVINEFIREROCKET,pDIVINEFIREROCKETTRAIL);
9402 1235 addsparkle2(pDIVINEFIREROCKETRETURN,pDIVINEFIREROCKETTRAILRETURN);
9403 1235 addsparkle2(pDIVINEPROTECTIONROCKET1,pDIVINEPROTECTIONROCKETTRAIL1);
9404 1235 addsparkle2(pDIVINEPROTECTIONROCKET2,pDIVINEPROTECTIONROCKETTRAIL2);
9405 1235 addsparkle2(pDIVINEPROTECTIONROCKETRETURN1,pDIVINEPROTECTIONROCKETTRAILRETURN1);
9406 1235 addsparkle2(pDIVINEPROTECTIONROCKETRETURN2,pDIVINEPROTECTIONROCKETTRAILRETURN2);
9407 1235 }
9408
9409 // Pay magic cost for Byrna beams
9410
9411 //Byrna needs a secondary timer, for 254+, as do all items that reduce MP on a per-frae basis. Essentially, we will do % divisor == 0 for that. -Z
9412
2/2
✓ Branch 0 taken 14309335 times.
✓ Branch 1 taken 73 times.
14309408 if(Lwpns.idCount(wCByrna))
9413 {
9414 73 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(wCByrna)));
9415 73 int32_t itemid = ew->parentitem;
9416
9417
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
73 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
9418 {
9419 for (int32_t i = 0; i < Lwpns.Count(); i++)
9420 {
9421 weapon* w = ((weapon*)Lwpns.spr(i));
9422
9423 if (w->id == wCByrna && !w->weapon_dying_frame)
9424 w->dead = 1;
9425 }
9426 //kill the sound effect for the orbits -Z 14FEB2019
9427 stop_sfx(itemsbuf[itemid].usesound);
9428 }
9429 73 else paymagiccost(itemid);
9430 73 }
9431
9432
3/4
✓ Branch 0 taken 14290302 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 14290302 times.
✗ Branch 3 not taken.
14309408 if(z==0&&fakez==0)
9433 {
9434 14290302 standing_on_z = 0;
9435
1/2
✓ Branch 0 taken 14290302 times.
✗ Branch 1 not taken.
14290302 if(standing_z_offset)
9436 {
9437 standing_z_offset=false;
9438 yofs += 8;
9439 }
9440 14290302 }
9441
2/2
✓ Branch 0 taken 319044 times.
✓ Branch 1 taken 13990364 times.
14309408 if(!isSideViewHero())
9442 {
9443 13990364 int32_t tx = x.getInt()+8,
9444 13990364 ty = y.getInt()+8;//(bigHitbox?8:12);
9445
4/4
✓ Branch 0 taken 13989928 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 368 times.
✓ Branch 3 taken 13989560 times.
13990364 if (unsigned(ty) < world_h && unsigned(tx) < world_w)
9446 {
9447 13989560 rpos_t rpos = COMBOPOS_REGION_B(tx, ty);
9448
2/2
✓ Branch 0 taken 13989060 times.
✓ Branch 1 taken 41968160 times.
55957220 for(int32_t q = 0; q < 3; ++q)
9449 {
9450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41968160 times.
41968160 if (rpos == rpos_t::None) break;
9451
9452 41968160 auto rpos_handle = get_rpos_handle(rpos, q);
9453
2/2
✓ Branch 0 taken 21793849 times.
✓ Branch 1 taken 20174311 times.
41968160 if (!rpos_handle.scr->is_valid()) continue;
9454
9455 21793849 auto& cmb = rpos_handle.combo();
9456
2/2
✓ Branch 0 taken 21788745 times.
✓ Branch 1 taken 5104 times.
21793849 bool standing_switchblock = cmb.type == cCSWITCHBLOCK && (cmb.usrflags & cflag9);
9457
2/2
✓ Branch 0 taken 21793813 times.
✓ Branch 1 taken 36 times.
21793849 bool standing_combo = (cmb.genflags & cflag3) && !standing_switchblock;
9458
4/4
✓ Branch 0 taken 21793377 times.
✓ Branch 1 taken 472 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 21793341 times.
21793849 if(!(standing_switchblock || standing_combo)) continue;
9459
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 36 times.
508 bool should_z_offs = standing_switchblock ? (cmb.usrflags&cflag10) : (cmb.genflags & cflag4);
9460
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 36 times.
508 zfix cmb_z = standing_switchblock ? zslongToFix(cmb.attributes[2]) : cmb.z_height;
9461 508 int32_t b = 1;
9462
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 146 times.
508 if(tx&8) b <<= 2;
9463
2/2
✓ Branch 0 taken 370 times.
✓ Branch 1 taken 138 times.
508 if(ty&8) b <<= 1;
9464 508 b |= (b<<4); //check equivalent effect flag too
9465
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 500 times.
508 if((cmb.walk&b)==b) //solid and effecting
9466 {
9467
3/4
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
500 if(z==0&&fakez==0)
9468 {
9469
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78 times.
78 if(should_z_offs)
9470 {
9471 if(!standing_z_offset)
9472 {
9473 standing_z_offset=true;
9474 yofs -= 8;
9475 }
9476 }
9477 else
9478 {
9479
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(standing_z_offset)
9480 {
9481 standing_z_offset=false;
9482 yofs += 8;
9483 }
9484 }
9485 78 }
9486
2/4
✓ Branch 0 taken 500 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500 times.
500 if(cmb_z>0 && standing_on_z>=0)
9487 {
9488
3/4
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
500 if(z==0&&fakez==0)
9489
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 standing_on_z = zc_max(standing_on_z,cmb_z);
9490
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 422 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422 times.
✓ Branch 4 taken 398 times.
✓ Branch 5 taken 24 times.
422 else if(STANDING_Z_STATE < cmb_z)
9491 {
9492
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
24 standing_on_z += cmb_z-STANDING_Z_STATE;
9493 24 }
9494 500 }
9495 else standing_on_z = -1;
9496 500 break;
9497 }
9498 8 }
9499 13989560 }
9500 13990364 }
9501 14309408 ClearhitHeroUIDs(); //clear them before we advance.
9502 14309408 checkhit();
9503
9504 14309408 bool forcedeath = dying_flags&DYING_FORCED;
9505 14309408 bool norev = (dying_flags&DYING_NOREV);
9506
4/6
✓ Branch 0 taken 14309408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 14308832 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 576 times.
14309408 if(forcedeath || (game->get_life()<=0 && !immortal))
9507 {
9508
1/2
✓ Branch 0 taken 576 times.
✗ Branch 1 not taken.
576 if(forcedeath)
9509 game->set_life(0);
9510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 576 times.
576 if(!norev)
9511
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 147456 times.
148032 for(size_t slot = 0; slot < 256; ++slot)
9512 {
9513
2/2
✓ Branch 0 taken 147448 times.
✓ Branch 1 taken 8 times.
147456 if(size_t bind = game->get_bottle_slot(slot))
9514 {
9515 8 bottletype const* bt = &QMisc.bottle_types[bind-1];
9516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!(bt->flags&BTFLAG_AUTOONDEATH))
9517 8 continue;
9518 word toFill[3] = { 0 };
9519 for(size_t q = 0; q < 3; ++q)
9520 {
9521 char c = bt->counter[q];
9522 if(c > -1)
9523 {
9524 if(bt->flags & (1<<q))
9525 {
9526 toFill[q] = (bt->amount[q]==100)
9527 ? game->get_maxcounter(c)
9528 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
9529 }
9530 else toFill[q] = bt->amount[q];
9531 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
9532 {
9533 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
9534 }
9535 }
9536 }
9537 if(bt->flags & BTFLAG_CURESWJINX)
9538 {
9539 swordclk = 0;
9540 verifyAWpn();
9541 }
9542 if(bt->flags & BTFLAG_CUREITJINX)
9543 itemclk = 0;
9544 if(bt->flags & BTFLAG_CURESHJINX)
9545 shieldjinxclk = 0;
9546 if(word max = std::max(toFill[0], std::max(toFill[1], toFill[2])))
9547 {
9548 int32_t itemid = find_bottle_for_slot(slot,true);
9549 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
9550 if(itemid > -1)
9551 sfx(itemsbuf[itemid].usesound,pan(x));
9552 for(size_t q = 0; q < 20; ++q)
9553 do_death_refill_waitframe();
9554 double inc = max/60.0; //1 second
9555 double xtra[3]{ 0 };
9556 for(size_t q = 0; q < 60; ++q)
9557 {
9558 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
9559 sfx(QMisc.miscsfx[sfxREFILL]);
9560 for(size_t j = 0; j < 3; ++j)
9561 {
9562 xtra[j] += inc;
9563 word f = floor(xtra[j]);
9564 xtra[j] -= f;
9565 if(toFill[j] > f)
9566 {
9567 toFill[j] -= f;
9568 game->change_counter(f,bt->counter[j]);
9569 }
9570 else if(toFill[j])
9571 {
9572 game->change_counter(toFill[j],bt->counter[j]);
9573 toFill[j] = 0;
9574 }
9575 }
9576 do_death_refill_waitframe();
9577 }
9578 for(size_t j = 0; j < 3; ++j)
9579 {
9580 if(toFill[j])
9581 {
9582 game->change_counter(toFill[j],bt->counter[j]);
9583 toFill[j] = 0;
9584 }
9585 }
9586 for(size_t q = 0; q < 20; ++q)
9587 do_death_refill_waitframe();
9588 }
9589 game->set_bottle_slot(slot,bt->next_type);
9590 if(game->get_life() > 0)
9591 {
9592 dying_flags = 0;
9593 forcedeath = false;
9594 break; //Revived! Stop drinking things...
9595 }
9596 }
9597 148024 }
9598
9599
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 500 times.
576 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
9600 {
9601
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 76 times.
76 if(forcedeath || (game->get_life()<=0 && !immortal)) //Not saved by fairy
9602 {
9603 // So scripts can have one frame to handle hp zero events
9604
3/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 43 times.
76 if(norev || false == (last_hurrah = !last_hurrah))
9605 {
9606 33 dying_flags = 0;
9607 33 drunkclk=0;
9608 33 lstunclock = 0;
9609 33 is_conveyor_stunned = 0;
9610 33 FFCore.setHeroAction(dying);
9611 33 FFCore.deallocateAllScriptOwned(ScriptType::Global, GLOBAL_SCRIPT_GAME);
9612 33 FFCore.deallocateAllScriptOwned(ScriptType::Hero, SCRIPT_HERO_ACTIVE);
9613 33 ALLOFF(true,true);
9614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(lift_wpn)
9615 {
9616 delete lift_wpn;
9617 lift_wpn = nullptr;
9618 }
9619 33 GameFlags |= GAMEFLAG_NO_F6;
9620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!debug_enabled)
9621 {
9622 33 Paused=false;
9623 33 }
9624
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 16 times.
33 if(!get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9625 {
9626 16 FFCore.runOnDeathEngine();
9627 16 FFCore.deallocateAllScriptOwned(ScriptType::Hero, SCRIPT_HERO_DEATH);
9628 16 }
9629 33 Playing = false;
9630 33 heroDeathAnimation();
9631
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 17 times.
33 if(get_qr(qr_ONDEATH_RUNS_AFTER_DEATH_ANIM))
9632 {
9633 17 Playing = true;
9634 17 FFCore.runOnDeathEngine();
9635 17 FFCore.deallocateAllScriptOwned(ScriptType::Hero, SCRIPT_HERO_DEATH);
9636 17 Playing = false;
9637 17 }
9638 33 GameFlags &= ~GAMEFLAG_NO_F6;
9639 33 ALLOFF(true,true);
9640 33 return true;
9641 }
9642 43 }
9643 43 }
9644 else //2.50.x
9645 {
9646 // So scripts can have one frame to handle hp zero events
9647
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 251 times.
500 if(false == (last_hurrah = !last_hurrah))
9648 {
9649 249 drunkclk=0;
9650 249 heroDeathAnimation();
9651
9652 249 return true;
9653 }
9654 }
9655 294 }
9656 14308832 else last_hurrah=false;
9657
9658
2/2
✓ Branch 0 taken 14259645 times.
✓ Branch 1 taken 49481 times.
14309126 if(swordclk>0)
9659 {
9660 49481 --swordclk;
9661
2/2
✓ Branch 0 taken 49143 times.
✓ Branch 1 taken 338 times.
49481 if(!swordclk) verifyAWpn();
9662 49481 }
9663
2/2
✓ Branch 0 taken 14299254 times.
✓ Branch 1 taken 9872 times.
14309126 if(itemclk>0)
9664 9872 --itemclk;
9665
1/2
✓ Branch 0 taken 14309126 times.
✗ Branch 1 not taken.
14309126 if(shieldjinxclk>0)
9666 --shieldjinxclk;
9667
9668
2/2
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 14307788 times.
14309126 if(inwallm)
9669 {
9670 1338 attackclk=0;
9671 1338 herostep();
9672
9673
2/2
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 9 times.
1338 if(CarryHero()==false)
9674 9 restart_level();
9675
9676 1338 solid_update(false);
9677 1338 return false;
9678 }
9679
9680
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 14307785 times.
14307788 if(ewind_restart)
9681 {
9682 3 attackclk=0;
9683 3 restart_level();
9684 3 xofs=0;
9685 3 action=none; FFCore.setHeroAction(none);
9686 3 ewind_restart=false;
9687 3 solid_update(false);
9688 3 return false;
9689 }
9690
9691
2/2
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 14304215 times.
14307785 if(fallclk)
9692 {
9693 3570 action=falling; FFCore.setHeroAction(falling);
9694 3570 }
9695
2/2
✓ Branch 0 taken 14290134 times.
✓ Branch 1 taken 14081 times.
14304215 else if(hopclk)
9696 {
9697 14081 action=hopping; FFCore.setHeroAction(hopping);
9698 14081 }
9699
9700
5/6
✓ Branch 0 taken 136379 times.
✓ Branch 1 taken 14171406 times.
✓ Branch 2 taken 1633 times.
✓ Branch 3 taken 134746 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1633 times.
14307785 if(isSwimming() && (liftflags&LIFTFL_DIS_SWIMMING) && !get_qr(qr_BROKEN_LIFTSWIM))
9701 1633 drop_liftwpn();
9702 14307785 handle_passive_buttons();
9703
2/2
✓ Branch 0 taken 936 times.
✓ Branch 1 taken 14306849 times.
14307785 if(liftclk)
9704 {
9705
1/2
✓ Branch 0 taken 936 times.
✗ Branch 1 not taken.
936 if(lift_wpn)
9706 {
9707 936 action=lifting; FFCore.setHeroAction(lifting);
9708 936 }
9709 else
9710 {
9711 liftclk = 0;
9712 tliftclk = 0;
9713 }
9714 936 }
9715
2/2
✓ Branch 0 taken 14297395 times.
✓ Branch 1 taken 9454 times.
14306849 else if(lift_wpn)
9716 {
9717 9454 handle_lift(false);
9718 9454 }
9719
9720 // get user input or do other animation
9721 14307785 freeze_guys=false; // reset this flag, set it again if holding
9722
9723
14/16
✓ Branch 0 taken 14186633 times.
✓ Branch 1 taken 121152 times.
✓ Branch 2 taken 14159671 times.
✓ Branch 3 taken 26962 times.
✓ Branch 4 taken 14158499 times.
✓ Branch 5 taken 1172 times.
✓ Branch 6 taken 14157848 times.
✓ Branch 7 taken 651 times.
✓ Branch 8 taken 14157848 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14157848 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 14134595 times.
✓ Branch 13 taken 23253 times.
✓ Branch 14 taken 14134478 times.
✓ Branch 15 taken 117 times.
14307785 if(action != landhold1 && action != landhold2 && action != waterhold1 && action != waterhold2 && action != sidewaterhold1 && action != sidewaterhold2 && fairyclk==0 && holdclk>0)
9724 {
9725 117 holdclk=0;
9726 117 }
9727
9728 14307785 active_shield_id = refreshActiveShield();
9729
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14307785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14307785 if (active_shield_id > -1 && !shield_active && on_cooldown(active_shield_id))
9730 active_shield_id = -1;
9731 14307785 bool sh = active_shield_id > -1;
9732 14307785 itemdata const& shield = itemsbuf[active_shield_id];
9733 //Handle direction forcing. This runs every frame so that scripts can interact with dir still.
9734 14307785 shield_forcedir = -1;
9735
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 14307785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14307785 if(sh && action != rafting && (shield.flags & item_flag11)) //Lock Dir
9736 {
9737 shield_forcedir = dir;
9738 }
9739
1/2
✓ Branch 0 taken 14307785 times.
✗ Branch 1 not taken.
14307785 if(sh != shield_active) //Toggle active shield on/off
9740 {
9741 shield_active = sh;
9742 if(sh) //Toggle active shield on
9743 {
9744 sfx(shield.usesound2); //'Activate' sfx
9745 start_cooldown(active_shield_id);
9746 }
9747 }
9748
9749 14307785 bool isthissolid = false;
9750
12/12
✓ Branch 0 taken 134909 times.
✓ Branch 1 taken 1823 times.
✓ Branch 2 taken 6272 times.
✓ Branch 3 taken 311389 times.
✓ Branch 4 taken 3887 times.
✓ Branch 5 taken 148114 times.
✓ Branch 6 taken 13561627 times.
✓ Branch 7 taken 102697 times.
✓ Branch 8 taken 3570 times.
✓ Branch 9 taken 14081 times.
✓ Branch 10 taken 18480 times.
✓ Branch 11 taken 936 times.
14307785 switch(action)
9751 {
9752 case gothit:
9753
2/2
✓ Branch 0 taken 100399 times.
✓ Branch 1 taken 2298 times.
102697 if(attackclk)
9754
2/2
✓ Branch 0 taken 1990 times.
✓ Branch 1 taken 308 times.
2606 if(!doattack())
9755 {
9756 308 attackclk=spins=0;
9757 308 tapping=false;
9758 308 }
9759
9760 102697 break;
9761
9762 case drowning:
9763 case lavadrowning:
9764 case sidedrowning:
9765 {
9766 6272 herostep(); // maybe this line should be elsewhere?
9767
9768 //!DROWN
9769 // Helpful comment to find drowning -Dimi
9770
9771 6272 drop_liftwpn();
9772
2/2
✓ Branch 0 taken 6174 times.
✓ Branch 1 taken 98 times.
6272 if(--drownclk==0)
9773 {
9774 98 action=none; FFCore.setHeroAction(none);
9775 98 optional<combined_handle_t> comb_handle;
9776 98 int32_t water = iswaterex_z3(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), -1, x.getInt()+7.5,y.getInt()+12, true, false, true, false, true, &comb_handle);
9777
3/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 34 times.
98 if(drownCombo && water != drownCombo)
9778 {
9779 34 comb_handle = nullopt;
9780 34 water = drownCombo;
9781 34 }
9782
9783 98 std::vector<int32_t> &ev = FFCore.eventData;
9784 98 ev.clear();
9785 98 ev.push_back(water*10000);
9786
9787 98 throwGenScriptEvent(GENSCR_EVENT_PLAYER_DROWN);
9788 98 water = ev[0]/10000;
9789 98 newcombo const& watercmb = combobuf[water];
9790
9791 98 int32_t damage = 4;
9792
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 30 times.
98 if (watercmb.type == cWATER)
9793 68 damage = watercmb.attributes[0]/10000L;
9794 30 else water = 0;
9795
9796
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
98 if(cheat_superman && damage > 0)
9797 damage = 0;
9798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(damage)
9799 98 game->set_life(vbound(game->get_life()-damage,0, game->get_maxlife()));
9800 98 drownCombo = 0;
9801
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 64 times.
98 if(comb_handle)
9802 64 do_trigger_ctype_causes(*comb_handle);
9803 98 go_respawn_point();
9804 98 hclk=48;
9805 98 check_on_hit();
9806 98 }
9807
9808 6272 break;
9809 }
9810 case falling:
9811 {
9812 3570 herostep();
9813 3570 pitfall();
9814 3570 break;
9815 }
9816 case freeze:
9817 case sideswimfreeze:
9818 case scrolling:
9819 311389 break;
9820
9821 case casting:
9822 case sideswimcasting:
9823 {
9824
2/2
✓ Branch 0 taken 3878 times.
✓ Branch 1 taken 9 times.
3887 if(magicitem==-1)
9825 {
9826 9 action=none; FFCore.setHeroAction(none);
9827 9 }
9828
9829 3887 break;
9830 }
9831 case landhold1:
9832 case landhold2:
9833 {
9834
2/2
✓ Branch 0 taken 1242 times.
✓ Branch 1 taken 146872 times.
148114 if(--holdclk <= 0)
9835 {
9836 //restart music
9837
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 1157 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 35 times.
1242 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9838 35 playLevelMusic();
9839
9840 1242 action=none; FFCore.setHeroAction(none);
9841 1242 post_item_collect();
9842 1242 }
9843 else
9844 146872 freeze_guys=true;
9845
9846 148114 break;
9847 }
9848 case waterhold1:
9849 case waterhold2:
9850 case sidewaterhold1:
9851 case sidewaterhold2:
9852 {
9853 1823 diveclk=0;
9854
9855
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1807 times.
1823 if(--holdclk <= 0)
9856 {
9857 //restart music
9858
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0 && (specialcave < GUYCAVE))
9859 playLevelMusic();
9860
9861 16 SetSwim();
9862 16 post_item_collect();
9863 16 }
9864 else
9865 1807 freeze_guys=true;
9866
9867 1823 break;
9868 }
9869 case hopping:
9870 {
9871
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 14068 times.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
14081 if(DRIEDLAKE)
9872 {
9873 action=none; FFCore.setHeroAction(none);
9874 hopclk = 0;
9875 diveclk = 0;
9876 break;
9877 }
9878
9879 14081 do_hopping();
9880 14081 break;
9881 }
9882 case inwind:
9883 {
9884 18480 int32_t i=Lwpns.idFirst(wWind);
9885
9886
2/2
✓ Branch 0 taken 18243 times.
✓ Branch 1 taken 237 times.
18480 if(i<0)
9887 {
9888 237 bool exit=false;
9889
9890
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 112 times.
237 if(whirlwind==255)
9891 {
9892 125 exit=true;
9893 125 }
9894 // When the wind weapon goes away, check if the player has been brought to the edge of the screen
9895 // by the wind. If so, push them one more pixel to trigger the screen scrolling code.
9896
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if (dir==up && y<=viewport.top()) y=viewport.top()-1;
9897
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if (dir==down && y>=viewport.bottom()-16) y=viewport.bottom()-16+1;
9898
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 112 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
112 else if (dir==left && x<=viewport.left()) x=viewport.left()-1;
9899
2/4
✓ Branch 0 taken 112 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 112 times.
112 else if (dir==right && x>=viewport.right()-16) x=viewport.right()-16+1;
9900 else exit=true;
9901
9902
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 125 times.
237 if(exit)
9903 {
9904 125 action=none; FFCore.setHeroAction(none);
9905 125 xofs=0;
9906 125 whirlwind=0;
9907 125 lstep=0;
9908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if ( dontdraw < 2 ) dontdraw=0;
9909 125 set_respawn_point();
9910 125 }
9911 237 }
9912 else
9913 {
9914 18243 auto wind = Lwpns.spr(i);
9915 18243 x = wind->x;
9916 18243 y = wind->y;
9917 18243 dir = wind->dir;
9918 }
9919 }
9920 18480 break;
9921 case lifting:
9922 936 handle_lift();
9923 936 break;
9924
9925 case sideswimming:
9926 case sideswimattacking:
9927 case sideswimhit:
9928 case swimhit:
9929 case swimming:
9930 {
9931
3/4
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 134743 times.
✓ Branch 2 taken 166 times.
✗ Branch 3 not taken.
134909 if(DRIEDLAKE)
9932 {
9933 action=none; FFCore.setHeroAction(none);
9934 hopclk=0;
9935 break;
9936 }
9937
9938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134909 times.
134909 bool shouldbreak = (action == sideswimhit || action == swimhit); //!DIMITODO: "Can walk while hurt" compat needs to be added here.
9939
9940
4/4
✓ Branch 0 taken 67399 times.
✓ Branch 1 taken 67510 times.
✓ Branch 2 taken 626 times.
✓ Branch 3 taken 66773 times.
134909 if((frame&1) && !shouldbreak)
9941 66773 herostep();
9942
9943
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 134909 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 134909 times.
✓ Branch 4 taken 10279 times.
✓ Branch 5 taken 124630 times.
145411 if (_walkflag(x+7,y+(bigHitbox?6:11),1,STANDING_Z_STATE)
9944
4/6
✓ Branch 0 taken 124407 times.
✓ Branch 1 taken 10502 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10502 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10502 times.
134909 || _walkflag(x+7,y+(bigHitbox?9:12),1,STANDING_Z_STATE)
9945
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 10493 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10493 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10493 times.
10502 || _walkflag(x+8,y+(bigHitbox?6:11),1,STANDING_Z_STATE)
9946
4/6
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 10279 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10279 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10279 times.
135123 || _walkflag(x+8,y+(bigHitbox?9:12),1,STANDING_Z_STATE)) isthissolid = true;
9947
4/4
✓ Branch 0 taken 126779 times.
✓ Branch 1 taken 8130 times.
✓ Branch 2 taken 126779 times.
✓ Branch 3 taken 8130 times.
134909 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) //Since hopping won't be set with this on, something needs to kick Hero out of water...
9948 {
9949
4/4
✓ Branch 0 taken 8082 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 8027 times.
✓ Branch 3 taken 4 times.
16161 if(!iswaterex_z3(MAPCOMBO(x.getInt()+4,y.getInt()+9), -1, x.getInt()+4,y.getInt()+9, true, false)||!iswaterex_z3(MAPCOMBO(x.getInt()+4,y.getInt()+15), -1, x.getInt()+4,y.getInt()+15, true, false)
9950
4/4
✓ Branch 0 taken 8058 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 8031 times.
✓ Branch 3 taken 27 times.
8082 || !iswaterex_z3(MAPCOMBO(x.getInt()+11,y.getInt()+9), -1, x.getInt()+11,y.getInt()+9, true, false)||!iswaterex_z3(MAPCOMBO(x.getInt()+11,y.getInt()+15), -1, x.getInt()+11,y.getInt()+15, true, false))
9951 {
9952 103 hopclk=0;
9953 103 diveclk=0;
9954
2/4
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
103 if (action != sideswimattacking && action != attacking) {action=none; FFCore.setHeroAction(none);}
9955 else {action=attacking; FFCore.setHeroAction(attacking);}
9956 103 hopdir=-1;
9957 103 }
9958 8130 }
9959
2/2
✓ Branch 0 taken 1259 times.
✓ Branch 1 taken 133650 times.
134909 if (shouldbreak) break;
9960
4/6
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 133547 times.
✓ Branch 2 taken 103 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 103 times.
133650 if (action == swimming || action == sideswimming || action == sideswimattacking)
9961 {
9962 133547 int32_t watercheck = iswaterex_z3(MAPCOMBO(x.getInt()+7.5,y.getInt()+12), -1, x.getInt()+7.5,y.getInt()+12, true, false);
9963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133547 times.
133547 if (combobuf[watercheck].usrflags&cflag2)
9964 {
9965 if (current_item(combobuf[watercheck].attribytes[2]) < combobuf[watercheck].attribytes[3])
9966 {
9967 onpassivedmg = true;
9968 if (damageovertimeclk == 0)
9969 {
9970 int32_t curhp = game->get_life();
9971 if (combobuf[watercheck].usrflags&cflag5) game->set_life(vbound(game->get_life()+ringpower(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife())); //Affected by rings
9972 else game->set_life(vbound(game->get_life()+(combobuf[watercheck].attributes[1]/10000L), 0, game->get_maxlife()));
9973 if ((combobuf[watercheck].attributes[2]/10000L) && (game->get_life() != curhp || !(combobuf[watercheck].usrflags&cflag6))) sfx(combobuf[watercheck].attributes[2]/10000L);
9974 if (game->get_life() < curhp && combobuf[watercheck].usrflags&cflag7)
9975 {
9976 hclk = 48;
9977 hitdir = -1;
9978 check_on_hit();
9979 if (IsSideSwim()) {action = sideswimhit; FFCore.setHeroAction(sideswimhit);}
9980 else {action = swimhit; FFCore.setHeroAction(swimhit);}
9981 }
9982 }
9983 if (combobuf[watercheck].attribytes[1] > 0)
9984 {
9985 if (!damageovertimeclk || damageovertimeclk > combobuf[watercheck].attribytes[1]) damageovertimeclk = combobuf[watercheck].attribytes[1];
9986 else --damageovertimeclk;
9987 }
9988 else damageovertimeclk = 0;
9989 }
9990 else damageovertimeclk = 0;
9991 }
9992 133547 else damageovertimeclk = 0;
9993 //combobuf[watercheck].attributes[0]
9994 133547 }
9995
9996 133650 }
9997 [[fallthrough]];
9998 default:
9999 // call the main movement routine
10000
2/2
✓ Branch 0 taken 402696 times.
✓ Branch 1 taken 13292581 times.
13695277 if(get_qr(qr_NEW_HERO_MOVEMENT2))
10001 {
10002
2/2
✓ Branch 0 taken 38022 times.
✓ Branch 1 taken 364674 times.
402696 if(premove())
10003 364674 movehero();
10004 402696 }
10005 else
10006 {
10007 13292581 sliding = 0;
10008 13292581 moveheroOld();
10009 }
10010 13695277 }
10011
12/16
✓ Branch 0 taken 319029 times.
✓ Branch 1 taken 13988756 times.
✓ Branch 2 taken 854 times.
✓ Branch 3 taken 318175 times.
✓ Branch 4 taken 854 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 834 times.
✓ Branch 7 taken 20 times.
✓ Branch 8 taken 816 times.
✓ Branch 9 taken 18 times.
✓ Branch 10 taken 816 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 816 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 816 times.
14307785 if (isSideViewHero() && slopeid && hoverclk < 1 && !inair && fall == 0 && !IsSideSwim() && justmoved <= 0 && !is_autowalking())
10012 {
10013
2/2
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 222 times.
816 if (!on_sideview_solid_oldpos(this, false, 0))
10014 {
10015 222 zfix dy = 0;
10016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 728 times.
728 for (zfix q = 0; q <= 4; ++q)
10017 {
10018
2/2
✓ Branch 0 taken 506 times.
✓ Branch 1 taken 222 times.
728 if (on_sideview_solid_oldpos(this, false, 0, 0, q))
10019 {
10020 222 dy = q;
10021 222 break;
10022 }
10023 506 }
10024
3/6
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 222 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222 times.
✗ Branch 5 not taken.
3634 dy = binary_search_zfix(0, dy, [&](zfix val, zfix& retval)
10025 {
10026
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 2398 times.
3412 if (on_sideview_solid_oldpos(this, false, 0, 0, val))
10027 {
10028 1014 retval = val;
10029 1014 return BSEARCH_CONTINUE_TOWARD0;
10030 }
10031 2398 else return BSEARCH_CONTINUE_AWAY0;
10032 3412 });
10033
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 110 times.
222 if (dy) push_move(0, dy);
10034 222 }
10035 816 }
10036
10037
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14307785 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14307785 if(shield_forcedir > -1 && action != rafting)
10038 dir = shield_forcedir;
10039
10040
10041 // check for ladder removal
10042
4/6
✓ Branch 0 taken 9749955 times.
✓ Branch 1 taken 4557830 times.
✓ Branch 2 taken 9749955 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9749955 times.
14307785 if(diagonalMovement||NO_GRIDLOCK)
10043 {
10044
2/2
✓ Branch 0 taken 4549169 times.
✓ Branch 1 taken 8661 times.
4557830 if(ladderx+laddery)
10045 {
10046
2/2
✓ Branch 0 taken 3309 times.
✓ Branch 1 taken 5352 times.
8661 if(ladderdir<=down)
10047 {
10048
10/10
✓ Branch 0 taken 2266 times.
✓ Branch 1 taken 1043 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 3241 times.
✓ Branch 4 taken 2229 times.
✓ Branch 5 taken 1012 times.
✓ Branch 6 taken 3210 times.
✓ Branch 7 taken 31 times.
✓ Branch 8 taken 5 times.
✓ Branch 9 taken 3205 times.
3309 if((laddery-y.getInt()>=(16+(ladderstart==dir?ladderstart==down?1:0:0))) || (laddery-y.getInt()<=(-16-(ladderstart==dir?ladderstart==up?1:0:0))) || (abs(ladderx-x.getInt())>8))
10049 {
10050 104 reset_ladder();
10051 104 }
10052 3309 }
10053 else
10054 {
10055
10/10
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5347 times.
✓ Branch 2 taken 4277 times.
✓ Branch 3 taken 1070 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 5283 times.
✓ Branch 6 taken 4245 times.
✓ Branch 7 taken 1038 times.
✓ Branch 8 taken 89 times.
✓ Branch 9 taken 5194 times.
5352 if((abs(laddery-y.getInt())>8) || (ladderx-x.getInt()>=(16+(ladderstart==dir?ladderstart==right?1:0:0))) || (ladderx-x.getInt()<=(-16-(ladderstart==dir?ladderstart==left?1:0:0))))
10056 {
10057 158 reset_ladder();
10058 158 }
10059 }
10060 8661 }
10061 4557830 }
10062 else
10063 {
10064
4/4
✓ Branch 0 taken 334176 times.
✓ Branch 1 taken 9415779 times.
✓ Branch 2 taken 194313 times.
✓ Branch 3 taken 139863 times.
9749955 if((abs(laddery-y.getInt())>=16) || (abs(ladderx-x.getInt())>=16))
10065 {
10066 9610092 reset_ladder();
10067 9610092 }
10068 }
10069
10070
2/2
✓ Branch 0 taken 13778682 times.
✓ Branch 1 taken 529103 times.
14307785 if(!get_qr(qr_OLD_RESPAWN_POINTS)) //needs to happen after ladder removal so the respawn point is set when laddering over multiple 1 tile gaps.
10071 529103 set_respawn_point(false); //Keep the 'last safe location' updated!
10072
10073
2/2
✓ Branch 0 taken 3222 times.
✓ Branch 1 taken 14304563 times.
14307785 if(ilswim)
10074 3222 landswim++;
10075 14304563 else landswim=0;
10076
10077
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 14307613 times.
14307785 if(hopclk!=0xFF) ilswim=false;
10078
10079
4/4
✓ Branch 0 taken 37969 times.
✓ Branch 1 taken 14269816 times.
✓ Branch 2 taken 3301 times.
✓ Branch 3 taken 34668 times.
14307785 if((!loaded_guys) && (frame - newscr_clk >= 1))
10080 {
10081
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 34651 times.
34668 if(hero_scr->room==rGANON)
10082 {
10083 17 ganon_intro();
10084 17 }
10085 else
10086 {
10087 34651 loadguys();
10088 }
10089 34668 }
10090
10091
2/2
✓ Branch 0 taken 40064 times.
✓ Branch 1 taken 14267721 times.
14307785 if(frame - newscr_clk >= 2)
10092 {
10093 14267721 loadenemies();
10094 14267721 }
10095
10096 // check lots of other things
10097 14307785 checkscroll();
10098
10099
7/8
✓ Branch 0 taken 14289430 times.
✓ Branch 1 taken 18355 times.
✓ Branch 2 taken 14283508 times.
✓ Branch 3 taken 5922 times.
✓ Branch 4 taken 14283508 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 251 times.
✓ Branch 7 taken 14283257 times.
14307785 if(action!=inwind && action!=drowning && action != sidedrowning && action!=lavadrowning)
10100 {
10101 14283257 checkspecial();
10102 14283257 checkitems();
10103
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14283256 times.
14283257 if(!is_autowalking())
10104 {
10105 14283256 checklocked(); //This has issues if Hero's action is WALKING, in 8-way moveent.
10106
2/2
✓ Branch 0 taken 567387 times.
✓ Branch 1 taken 13715869 times.
14283256 if(get_qr(qr_OLD_LOCKBLOCK_COLLISION))
10107 {
10108 13715869 oldchecklockblock();
10109 13715869 oldcheckbosslockblock();
10110 13715869 }
10111
2/2
✓ Branch 0 taken 1053318 times.
✓ Branch 1 taken 13229938 times.
14283256 if(get_qr(qr_OLD_CHEST_COLLISION))
10112 {
10113 13229938 oldcheckchest(cCHEST);
10114 13229938 oldcheckchest(cLOCKEDCHEST);
10115 13229938 oldcheckchest(cBOSSCHEST);
10116 13229938 }
10117 14283256 checkpushblock();
10118 14283256 checkswordtap();
10119 14283256 }
10120
10121
2/2
✓ Branch 0 taken 47397 times.
✓ Branch 1 taken 14235858 times.
14283257 if(hookshot_frozen==false)
10122 {
10123 14235858 checkspecial2(&lsave);
10124 14235858 }
10125
10126
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 14283245 times.
14283255 if(action==won)
10127 {
10128 10 return true;
10129 }
10130 14283245 }
10131
10132 // Somehow Hero was displaced from the fairy flag...
10133
3/6
✓ Branch 0 taken 23254 times.
✓ Branch 1 taken 14284519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23254 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
14307773 if(fairyclk && action != freeze && action != sideswimfreeze)
10134 {
10135 fairyclk = holdclk = refill_why = 0;
10136 }
10137
10138
4/4
✓ Branch 0 taken 14307773 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 82910 times.
✓ Branch 3 taken 14224863 times.
14307773 if((!activated_timed_warp) && (origin_scr->timedwarptics>0))
10139 {
10140 82910 origin_scr->timedwarptics--;
10141
10142
2/2
✓ Branch 0 taken 82411 times.
✓ Branch 1 taken 499 times.
82910 if(origin_scr->timedwarptics==0)
10143 {
10144 499 activated_timed_warp=true;
10145
10146
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 121 times.
499 if(origin_scr->flags4 & fTIMEDDIRECT)
10147 {
10148 121 setpit();
10149 121 }
10150
10151 499 int32_t index2 = 0;
10152
10153
1/2
✓ Branch 0 taken 499 times.
✗ Branch 1 not taken.
499 if(origin_scr->flags5 & fRANDOMTIMEDWARP) index2=zc_oldrand()%4;
10154
10155 499 sdir = dir;
10156 499 dowarp(origin_scr, 1, index2);
10157 499 }
10158 82910 }
10159
10160 // Global Combo Effects (AUTO STUFF)
10161 14307775 bool awarp = false;
10162 4044734303 for_some_rpos([&](const rpos_handle_t& rpos_handle) {
10163
2/2
✓ Branch 0 taken 273941185 times.
✓ Branch 1 taken 3756485343 times.
4030426528 if (!get_qr(qr_AUTOCOMBO_ANY_LAYER))
10164 {
10165
2/2
✓ Branch 0 taken 4762155 times.
✓ Branch 1 taken 3751723188 times.
3756485343 if (rpos_handle.layer > 2) return false;
10166
4/4
✓ Branch 0 taken 946477664 times.
✓ Branch 1 taken 2805245524 times.
✓ Branch 2 taken 48259552 times.
✓ Branch 3 taken 898218112 times.
3751723188 if (rpos_handle.layer == 1 && !get_qr(qr_AUTOCOMBO_LAYER_1)) return true;
10167
4/4
✓ Branch 0 taken 341433312 times.
✓ Branch 1 taken 2512071764 times.
✓ Branch 2 taken 19404000 times.
✓ Branch 3 taken 322029312 times.
2853505076 if (rpos_handle.layer == 2 && !get_qr(qr_AUTOCOMBO_LAYER_2)) return true;
10168 2531475764 }
10169 2805416949 int32_t ind=0;
10170
10171 //AUTOMATIC TRIGGER CODE
10172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2805416949 times.
2986772879 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
10173 181355930 return trig.trigger_flags.get(TRIGFLAG_AUTOMATIC);
10174 });
10175 2805416949 newcombo const& cmb = rpos_handle.combo();
10176
10177 //AUTO WARP CODE
10178
2/2
✓ Branch 0 taken 22695 times.
✓ Branch 1 taken 2805394254 times.
2805416949 if (!(cmb.only_gentrig))
10179 {
10180
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 2805394165 times.
2805394254 if(cmb.type==cAWARPA)
10181 {
10182 89 awarp=true;
10183 89 ind=0;
10184 89 }
10185
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 2805394102 times.
2805394165 else if(cmb.type==cAWARPB)
10186 {
10187 63 awarp=true;
10188 63 ind=1;
10189 63 }
10190
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2805394099 times.
2805394102 else if(cmb.type==cAWARPC)
10191 {
10192 3 awarp=true;
10193 3 ind=2;
10194 3 }
10195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2805394099 times.
2805394099 else if(cmb.type==cAWARPD)
10196 {
10197 awarp=true;
10198 ind=3;
10199 }
10200
1/2
✓ Branch 0 taken 2805394099 times.
✗ Branch 1 not taken.
2805394099 else if(cmb.type==cAWARPR)
10201 {
10202 awarp=true;
10203 ind=zc_oldrand()%4;
10204 }
10205 2805394254 }
10206
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 2805416794 times.
2805416949 if (awarp)
10207 {
10208
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 67 times.
155 if (rpos_handle.scr->flags5 & fDIRECTAWARP)
10209 {
10210 67 setpit();
10211 67 }
10212
10213 155 sdir = dir;
10214 155 dowarp(rpos_handle.scr, 1, ind);
10215 155 return false;
10216 }
10217
10218 2805416794 return true;
10219 4030426528 });
10220
10221 14307775 awarp=false;
10222
10223 453811719 for_some_ffcs([&](const ffc_handle_t& ffc_handle) {
10224 439503944 int32_t ind=0;
10225
10226
1/2
✓ Branch 0 taken 439503944 times.
✗ Branch 1 not taken.
439628945 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
10227 125001 return trig.trigger_flags.get(TRIGFLAG_AUTOMATIC);
10228 });
10229 439503944 auto& cmb = ffc_handle.combo();
10230
10231
2/2
✓ Branch 0 taken 3908 times.
✓ Branch 1 taken 439500036 times.
439503944 if(!(cmb.only_gentrig))
10232 {
10233
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 439500017 times.
439500036 if(cmb.type==cAWARPA)
10234 {
10235 19 awarp=true;
10236 19 ind=0;
10237 19 }
10238
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 439499984 times.
439500017 else if(cmb.type==cAWARPB)
10239 {
10240 33 awarp=true;
10241 33 ind=1;
10242 33 }
10243
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 439499982 times.
439499984 else if(cmb.type==cAWARPC)
10244 {
10245 2 awarp=true;
10246 2 ind=2;
10247 2 }
10248
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 439499978 times.
439499982 else if(cmb.type==cAWARPD)
10249 {
10250 4 awarp=true;
10251 4 ind=3;
10252 4 }
10253
1/2
✓ Branch 0 taken 439499978 times.
✗ Branch 1 not taken.
439499978 else if(cmb.type==cAWARPR)
10254 {
10255 awarp=true;
10256 ind=zc_oldrand()%4;
10257 }
10258 439500036 }
10259
10260
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 439503886 times.
439503944 if(awarp)
10261 {
10262
1/2
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
58 if(ffc_handle.scr->flags5&fDIRECTAWARP)
10263 {
10264 setpit();
10265 }
10266
10267 58 sdir = dir;
10268 58 dowarp(ffc_handle.scr, 1, ind, 0);
10269 58 return false;
10270 }
10271
10272 439503886 return true;
10273 439503944 });
10274
10275 14307775 zfix dx, dy;
10276
8/10
✓ Branch 0 taken 319028 times.
✓ Branch 1 taken 13988747 times.
✓ Branch 2 taken 158801 times.
✓ Branch 3 taken 160227 times.
✓ Branch 4 taken 746 times.
✓ Branch 5 taken 158055 times.
✓ Branch 6 taken 746 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 746 times.
14307775 if (sideview_mode() && !on_sideview_solid_oldpos(this, false, 1) && on_sideview_solid_oldpos(this, false, 2) && !toogam && !is_autowalking())
10277 {
10278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 746 times.
746 if (slide_slope(this, dx, dy, slopeid))
10279 {
10280 746 onplatid = 1;
10281
2/4
✓ Branch 0 taken 746 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 746 times.
746 if (dx || dy) push_move(dx, dy);
10282 746 }
10283 746 }
10284
2/2
✓ Branch 0 taken 14306937 times.
✓ Branch 1 taken 838 times.
14307775 if (onplatid <= 0) slopeid = 0;
10285 838 else --onplatid;
10286
2/2
✓ Branch 0 taken 11356229 times.
✓ Branch 1 taken 2951546 times.
14307775 bool onplatform = (on_sideview_solid_oldpos(this, false, 1) && !getInput(btnUp, INPUT_HERO_ACTION));
10287
3/4
✓ Branch 0 taken 14292820 times.
✓ Branch 1 taken 14955 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14292820 times.
14307775 if(!toogam && !is_autowalking())
10288 {
10289
4/4
✓ Branch 0 taken 14292817 times.
✓ Branch 1 taken 1964 times.
✓ Branch 2 taken 1961 times.
✓ Branch 3 taken 14292820 times.
14294781 for (auto q = 0; check_slope(this, true) && q < 2; ++q)
10290 {
10291 1961 dx = 0;
10292 1961 dy = 0;
10293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1961 times.
1961 if (check_slope(this, true))
10294 {
10295 1961 slope_info const& s = get_slope(this, true).get_info();
10296 1961 bool staircheck = false;
10297
3/4
✓ Branch 0 taken 1815 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 1815 times.
✗ Branch 3 not taken.
1961 if (s.slope() != slopeid && slopeid) staircheck = true;
10298
2/2
✓ Branch 0 taken 1914 times.
✓ Branch 1 taken 47 times.
1961 if (onplatform) staircheck = true;
10299 1961 slope_push_int(s, this, dx, dy, staircheck, platformfell2);
10300
10301
4/4
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 1780 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 1 times.
1961 if (dx || dy)
10302 {
10303 1960 reset_hookshot();
10304 1960 int32_t pushret = push_move(dx,dy);
10305
2/2
✓ Branch 0 taken 1945 times.
✓ Branch 1 taken 15 times.
1960 onplatform = (on_sideview_solid_oldpos(this, false, 1) && !getInput(btnUp, INPUT_HERO_ACTION));
10306
3/4
✓ Branch 0 taken 1814 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 1814 times.
✗ Branch 3 not taken.
1960 if (s.slope() != slopeid && slopeid) staircheck = true;
10307
2/2
✓ Branch 0 taken 1945 times.
✓ Branch 1 taken 15 times.
1960 if (onplatform) staircheck = true;
10308
4/4
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 1776 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 146 times.
1960 if(sideview_mode() && slopeid)
10309 146 onplatid = 0;
10310
1/2
✓ Branch 0 taken 1960 times.
✗ Branch 1 not taken.
1960 if (pushret == 1)
10311 {
10312 dx = -1;
10313 dy = 0;
10314 slope_push_int(s, this, dx, dy, staircheck);
10315 push_move(0,dy);
10316 }
10317
2/2
✓ Branch 0 taken 1959 times.
✓ Branch 1 taken 1 times.
1960 if (pushret == 2)
10318 {
10319 1 dx = 0;
10320 1 dy = -1;
10321 1 slope_push_int(s, this, dx, dy, staircheck);
10322 1 push_move(dx,0);
10323 1 }
10324 1960 }
10325 1961 }
10326 1961 }
10327 14292820 }
10328
10329
2/2
✓ Branch 0 taken 14307541 times.
✓ Branch 1 taken 234 times.
14307775 if(ffwarp)
10330 {
10331
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 127 times.
234 if(ffpit)
10332 {
10333 127 ffpit=false;
10334 127 setpit();
10335 127 }
10336
10337 234 ffwarp=false;
10338 234 dowarp(hero_scr,1,0);
10339 234 }
10340
10341 //Hero->WarpEx
10342
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 14307669 times.
14307775 if ( FFCore.warpex[wexActive] )
10343 {
10344 if(DEVLOGGING) zprint("Running warpex from hero.cpp\n");
10345 106 FFCore.warpex[wexActive] = 0;
10346 106 int32_t temp_warpex[wexActive] = {0}; //to hold the values as we clear the FFCore array. -Z
10347
2/2
✓ Branch 0 taken 954 times.
✓ Branch 1 taken 106 times.
1060 for ( int32_t q = 0; q < wexActive; q++ )
10348 {
10349 954 temp_warpex[q] = FFCore.warpex[q];
10350 954 FFCore.warpex[q] = 0;
10351 954 }
10352 212 FFCore.warp_player( temp_warpex[wexType], temp_warpex[wexDMap], temp_warpex[wexScreen], temp_warpex[wexX],
10353 106 temp_warpex[wexY], temp_warpex[wexEffect], temp_warpex[wexSound], temp_warpex[wexFlags], temp_warpex[wexDir]);
10354 106 }
10355
10356
4/4
✓ Branch 0 taken 19107 times.
✓ Branch 1 taken 14288668 times.
✓ Branch 2 taken 29187 times.
✓ Branch 3 taken 33526 times.
14307775 if(z == 0 || !get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
10357 {
10358 // walk through bombed doors and fake walls
10359 14322194 bool walk=false;
10360 14322194 int32_t dtype=dBOMBED;
10361
10362
2/2
✓ Branch 0 taken 13958197 times.
✓ Branch 1 taken 296945 times.
14322194 if(pushing>=24) dtype=dWALK;
10363
10364
17/20
✓ Branch 0 taken 6270359 times.
✓ Branch 1 taken 7984783 times.
✓ Branch 2 taken 6133753 times.
✓ Branch 3 taken 136606 times.
✓ Branch 4 taken 6133753 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6122412 times.
✓ Branch 7 taken 11341 times.
✓ Branch 8 taken 6118991 times.
✓ Branch 9 taken 3421 times.
✓ Branch 10 taken 6111784 times.
✓ Branch 11 taken 7207 times.
✓ Branch 12 taken 6098072 times.
✓ Branch 13 taken 13712 times.
✓ Branch 14 taken 6098072 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 6098072 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 92698 times.
✓ Branch 19 taken 6190770 times.
14255142 if(isdungeon() && action!=freeze && action != sideswimfreeze && loaded_guys && !inlikelike && !diveclk && action!=rafting && !lstunclock && !is_conveyor_stunned && !is_autowalking())
10365 {
10366 6190770 int x0 = x.getInt() % 256;
10367 6190770 int y0 = y.getInt() % 176;
10368
10369
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6061770 times.
✓ Branch 2 taken 1018756 times.
✓ Branch 3 taken 5043014 times.
✓ Branch 4 taken 1013652 times.
✓ Branch 5 taken 5104 times.
✓ Branch 6 taken 1013652 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1013652 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 946981 times.
✓ Branch 11 taken 941877 times.
✓ Branch 12 taken 66446 times.
✓ Branch 13 taken 225 times.
6190770 if (((dtype == dBOMBED) ? getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) : dir == up) && ((diagonalMovement || NO_GRIDLOCK) ? x0 > 112 && x0 < 128:x0 == 120) && y0 <= 32 && hero_scr->door[0] == dtype)
10370 {
10371 225 walk=true;
10372 225 dir=up;
10373 225 }
10374
10375
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6051562 times.
✓ Branch 2 taken 733936 times.
✓ Branch 3 taken 5317626 times.
✓ Branch 4 taken 858767 times.
✓ Branch 5 taken 4169 times.
✓ Branch 6 taken 858767 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 858767 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 815443 times.
✓ Branch 11 taken 811274 times.
✓ Branch 12 taken 43108 times.
✓ Branch 13 taken 216 times.
6180562 if (((dtype == dBOMBED) ? getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) : dir == down) && ((diagonalMovement || NO_GRIDLOCK) ? x0 > 112 && x0 < 128:x0 == 120) && y0 >= 128 && hero_scr->door[1] == dtype)
10376 {
10377 216 walk=true;
10378 216 dir=down;
10379 216 }
10380
10381
12/14
✓ Branch 0 taken 129000 times.
✓ Branch 1 taken 6043224 times.
✓ Branch 2 taken 46925 times.
✓ Branch 3 taken 5996299 times.
✓ Branch 4 taken 101764 times.
✓ Branch 5 taken 219 times.
✓ Branch 6 taken 101764 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 101764 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 105 times.
✓ Branch 11 taken 114 times.
✓ Branch 12 taken 101589 times.
✓ Branch 13 taken 101484 times.
6172224 if (((dtype == dBOMBED) ? getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) : dir == left) && x0 <= 32 && ((diagonalMovement || NO_GRIDLOCK) ? y0 > 72 && y0 < 88:y0 == 80) && hero_scr->door[2] == dtype)
10382 {
10383 175 walk=true;
10384 175 dir=left;
10385 175 }
10386
10387
12/14
✓ Branch 0 taken 5969072 times.
✓ Branch 1 taken 129000 times.
✓ Branch 2 taken 41187 times.
✓ Branch 3 taken 5927885 times.
✓ Branch 4 taken 122261 times.
✓ Branch 5 taken 92 times.
✓ Branch 6 taken 122261 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 122261 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 58 times.
✓ Branch 11 taken 34 times.
✓ Branch 12 taken 122066 times.
✓ Branch 13 taken 122008 times.
6098072 if (((dtype == dBOMBED) ? getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) : dir == right) && x0 >= 208 && ((diagonalMovement || NO_GRIDLOCK) ? y0 > 72 && y0 < 88:y0 == 80) && hero_scr->door[3] == dtype)
10388 {
10389 195 walk=true;
10390 195 dir=right;
10391 195 }
10392 6050122 }
10393
10394
2/2
✓ Branch 0 taken 14299079 times.
✓ Branch 1 taken 811 times.
14299890 if(walk)
10395 {
10396 811 hclk=0;
10397 811 drawguys=false;
10398
10399
2/2
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 195 times.
811 if(dtype==dWALK)
10400 {
10401 195 sfx(hero_scr->secretsfx);
10402
1/2
✓ Branch 0 taken 195 times.
✗ Branch 1 not taken.
195 if(!get_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE))
10403 set_doorstate(current_screen, dir);
10404 195 }
10405
10406 811 action=none; FFCore.setHeroAction(none);
10407 811 attackclk = 0;
10408 811 stepforward(29, true);
10409 811 action=scrolling; FFCore.setHeroAction(scrolling);
10410 811 pushing=false;
10411 811 }
10412 14299890 }
10413
10414
5/6
✓ Branch 0 taken 338291 times.
✓ Branch 1 taken 13990786 times.
✓ Branch 2 taken 335798 times.
✓ Branch 3 taken 2493 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 335798 times.
14329077 if( game->get_life() <= (game->get_hp_per_heart()) && !(game->get_maxlife() <= (game->get_hp_per_heart())) && (heart_beep_timer > -3))
10415 {
10416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 335798 times.
335798 if(heart_beep)
10417 {
10418 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
10419 }
10420 else
10421 {
10422
2/2
✓ Branch 0 taken 335263 times.
✓ Branch 1 taken 535 times.
335798 if ( heart_beep_timer == -1 )
10423 {
10424 535 heart_beep_timer = 70;
10425 535 }
10426
10427
2/2
✓ Branch 0 taken 29912 times.
✓ Branch 1 taken 305886 times.
335798 if ( heart_beep_timer > 0 )
10428 {
10429 29912 --heart_beep_timer;
10430 29912 cont_sfx(QMisc.miscsfx[sfxLOWHEART]);
10431 29912 }
10432 else
10433 {
10434 305886 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
10435 }
10436 }
10437 335798 }
10438 else
10439 {
10440
2/2
✓ Branch 0 taken 27076 times.
✓ Branch 1 taken 13971975 times.
13993279 if ( heart_beep_timer > -2 )
10441 {
10442 13971975 heart_beep_timer = -1;
10443 13971975 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
10444 13971975 }
10445 }
10446
10447
2/2
✓ Branch 0 taken 14333417 times.
✓ Branch 1 taken 1432 times.
14334849 if (getInput(btnS, INPUT_PRESS | INPUT_HERO_ACTION))
10448 {
10449 1432 int32_t tmp_subscr_clk = frame;
10450
10451 1432 int32_t save_type = 0;
10452
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1424 times.
✗ Branch 3 not taken.
1432 switch(lsave)
10453 {
10454 case 0:
10455 {
10456
2/2
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 1383 times.
1424 if( FFCore.runScriptedActiveSusbcreen() )
10457 {
10458 41 break;
10459 }
10460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1383 times.
1383 else if ( !stopSubscreenFalling() )
10461 {
10462 1383 conveyclk=3;
10463 1383 dosubscr();
10464 1383 newscr_clk += frame - tmp_subscr_clk;
10465 1383 }
10466 1383 break;
10467 }
10468
10469 case 2:
10470 save_type = 1;
10471 [[fallthrough]];
10472 case 1:
10473
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(last_savepoint_id)
10474 7 trigger_save(combobuf[last_savepoint_id], hero_scr);
10475 else save_game((hero_scr->flags4&fSAVEROOM) != 0, save_type); //sanity?
10476 7 break;
10477 }
10478 1432 }
10479
10480
2/2
✓ Branch 0 taken 814154 times.
✓ Branch 1 taken 13520693 times.
14334847 if (!checkstab() )
10481 {
10482 13520693 }
10483
10484 14334847 check_conveyor();
10485 14334847 PhantomsCleanup();
10486 //Try to time the hammer pound so that Hero can;t change direction while it occurs.
10487
2/2
✓ Branch 0 taken 14130464 times.
✓ Branch 1 taken 204383 times.
14334847 if(attack==wHammer)
10488 {
10489
6/8
✓ Branch 0 taken 2172 times.
✓ Branch 1 taken 202211 times.
✓ Branch 2 taken 2172 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2172 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 2167 times.
204383 if(attackclk==12 && z==0 && fakez==0 && sideviewhammerpound())
10490 {
10491
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 341 times.
✓ Branch 2 taken 508 times.
✓ Branch 3 taken 717 times.
✓ Branch 4 taken 601 times.
2167 switch(dir) //Hero's dir
10492 {
10493 case up:
10494
5/10
✓ Branch 0 taken 341 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 341 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 341 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 341 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 341 times.
✗ Branch 9 not taken.
341 decorations.add(new dHammerSmack(x-1, y-4, dHAMMERSMACK, 0));
10495 341 break;
10496
10497 case down:
10498
5/10
✓ Branch 0 taken 508 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 508 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 508 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 508 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 508 times.
✗ Branch 9 not taken.
508 decorations.add(new dHammerSmack(x+8, y+28, dHAMMERSMACK, 0));
10499 508 break;
10500
10501 case left:
10502
5/10
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 717 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 717 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 717 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 717 times.
✗ Branch 9 not taken.
717 decorations.add(new dHammerSmack(x-13, y+14, dHAMMERSMACK, 0));
10503 717 break;
10504
10505 case right:
10506
5/10
✓ Branch 0 taken 601 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 601 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 601 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 601 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 601 times.
✗ Branch 9 not taken.
601 decorations.add(new dHammerSmack(x+21, y+14, dHAMMERSMACK, 0));
10507 601 break;
10508 }
10509
10510 2167 }
10511 204383 }
10512
10513 14334847 handleSpotlights();
10514
10515
2/2
✓ Branch 0 taken 14334527 times.
✓ Branch 1 taken 320 times.
14334847 if(getOnSideviewLadder())
10516 {
10517
5/8
✓ Branch 0 taken 311 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 311 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 311 times.
320 if(!canSideviewLadder() || jumping<0 || fall!=0 || fakefall!=0)
10518 {
10519 9 setOnSideviewLadder(false);
10520 9 }
10521
4/8
✓ Branch 0 taken 311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✓ Branch 3 taken 233 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 78 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
311 else if(CANFORCEFACEUP)
10522 {
10523 78 setDir(up);
10524 78 }
10525 320 }
10526
2/2
✓ Branch 0 taken 270373 times.
✓ Branch 1 taken 14064474 times.
14334847 if (justmoved > 0) --justmoved;
10527 14334847 return false;
10528 14336480 }
10529
10530 5284 bool HeroClass::push_pixel(zfix dx, zfix dy)
10531 {
10532 ASSERT(abs(dx) <= 1 && abs(dy) <= 1);
10533
3/4
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 2952 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
5284 if(dx && dy)
10534 {
10535 bool r = push_pixel(0,dy);
10536 bool r2 = push_pixel(dx,0);
10537 return r && r2;
10538 }
10539
2/2
✓ Branch 0 taken 1072 times.
✓ Branch 1 taken 4212 times.
5284 if(dx < 0)
10540 {
10541
1/2
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
2144 if(!(solpush_walkflag(x+dx,y+(bigHitbox?0:8),1,this)
10542
1/2
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
1072 || solpush_walkflag(x+dx,y+8,1,this)
10543
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1072 times.
✓ Branch 2 taken 950 times.
✓ Branch 3 taken 122 times.
1072 || (y.getInt()&7?solpush_walkflag(x+dx,y+16,1,this):0)))
10544 {
10545 1072 x += dx;
10546 1072 return true;
10547 }
10548 return false;
10549 }
10550
2/2
✓ Branch 0 taken 1260 times.
✓ Branch 1 taken 2952 times.
4212 else if(dx > 0)
10551 {
10552
2/2
✓ Branch 0 taken 1224 times.
✓ Branch 1 taken 36 times.
2504 if(!(solpush_walkflag(x+15+dx,y+(bigHitbox?0:8),1,this)
10553
2/2
✓ Branch 0 taken 1244 times.
✓ Branch 1 taken 16 times.
1260 || solpush_walkflag(x+15+dx,y+8,1,this)
10554
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1244 times.
✓ Branch 2 taken 1037 times.
✓ Branch 3 taken 207 times.
1244 || (y.getInt()&7?solpush_walkflag(x+15+dx,y+16,1,this):0)))
10555 {
10556 1224 x += dx;
10557 1224 return true;
10558 }
10559 36 return false;
10560 }
10561
2/2
✓ Branch 0 taken 1378 times.
✓ Branch 1 taken 1574 times.
2952 else if(dy < 0)
10562 {
10563
2/2
✓ Branch 0 taken 1377 times.
✓ Branch 1 taken 1 times.
2755 if(!(solpush_walkflag(x,y+(bigHitbox?0:8)+dy,2,this)
10564
4/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1377 times.
✓ Branch 2 taken 1169 times.
✓ Branch 3 taken 208 times.
1378 || (x.getInt()&7?solpush_walkflag(x+16,y+(bigHitbox?0:8)+dy,1,this):0)))
10565 {
10566 1377 y += dy;
10567 1377 return true;
10568 }
10569 1 return false;
10570 }
10571
1/2
✓ Branch 0 taken 1574 times.
✗ Branch 1 not taken.
1574 else if(dy > 0)
10572 {
10573
2/2
✓ Branch 0 taken 1544 times.
✓ Branch 1 taken 30 times.
3118 if(!(solpush_walkflag(x,y+15+dy,2,this)
10574
4/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1544 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 1354 times.
1574 || (x.getInt()&7?solpush_walkflag(x+16,y+15+dy,1,this):0)))
10575 {
10576 1544 y += dy;
10577 1544 return true;
10578 }
10579 30 return false;
10580 }
10581 return false;
10582 5284 }
10583 2509 int32_t HeroClass::push_move(zfix dx, zfix dy)
10584 {
10585 2509 int32_t ret = 0;
10586
4/4
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 3579 times.
✓ Branch 2 taken 2509 times.
✓ Branch 3 taken 3402 times.
5911 while(dx || dy)
10587 {
10588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3402 times.
3402 if(check_pitslide() != -1)
10589 break;
10590
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 2952 times.
3402 if(dy)
10591 {
10592
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 2228 times.
2952 zfix cy = (abs(dy) >= 1) ? sign(dy) : dy;
10593 2952 dy -= cy;
10594
2/2
✓ Branch 0 taken 2921 times.
✓ Branch 1 taken 31 times.
2952 if(!push_pixel(0,cy))
10595 {
10596 31 dy = 0;
10597 31 ret |= 2;
10598 31 }
10599 2952 }
10600
2/2
✓ Branch 0 taken 1070 times.
✓ Branch 1 taken 2332 times.
3402 if(dx)
10601 {
10602
2/2
✓ Branch 0 taken 555 times.
✓ Branch 1 taken 1777 times.
2332 zfix cx = (abs(dx) >= 1) ? sign(dx) : dx;
10603 2332 dx -= cx;
10604
2/2
✓ Branch 0 taken 2296 times.
✓ Branch 1 taken 36 times.
2332 if(!push_pixel(cx,0))
10605 {
10606 36 dx = 0;
10607 36 ret |= 1;
10608 36 }
10609 2332 }
10610 }
10611 2509 return ret;
10612 }
10613
10614 14309113 bool HeroClass::setSolid(bool set)
10615 {
10616
1/2
✓ Branch 0 taken 14309113 times.
✗ Branch 1 not taken.
14309113 bool actual = set && !toogam; //not solid when noclipping
10617 14309113 bool ret = solid_object::setSolid(actual);
10618 14309113 solid = set;
10619 14309113 return ret;
10620 }
10621
10622 18082 void HeroClass::solid_push(solid_object* obj)
10623 {
10624
1/2
✓ Branch 0 taken 18082 times.
✗ Branch 1 not taken.
18082 if(obj == this) return; //can't push self
10625
10626 18082 zfix dx, dy;
10627 18082 int32_t hdir = -1;
10628 18082 solid_push_int(obj,dx,dy,hdir,!on_ffc_platform());
10629
10630
4/4
✓ Branch 0 taken 17992 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 17756 times.
✓ Branch 3 taken 236 times.
18082 if(!dx && !dy) return;
10631
10632 326 obj->doContactDamage(hdir);
10633
10634 326 bool t = obj->getTempNonsolid();
10635 326 obj->setTempNonsolid(true);
10636
10637 326 push_move(dx,dy);
10638
10639 326 obj->setTempNonsolid(t);
10640 18082 }
10641
10642 #define COND_AWPN (get_qr(qr_SELECTAWPN) ? game->awpn : 255)
10643 #define COND_BWPN (game->bwpn)
10644 #define COND_XWPN (get_qr(qr_SET_XBUTTON_ITEMS) ? game->xwpn : 255)
10645 #define COND_YWPN (get_qr(qr_SET_YBUTTON_ITEMS) ? game->ywpn : 255)
10646 //Helper function
10647 1330 static void deselectbombsWPN(word& wpos, int32_t& BTNwpn, int32_t& directItemBTN,
10648 word f1 = 255, word f2 = 255, word f3 = 255)
10649 {
10650 1330 byte pgn = wpos&0xFF, pos = wpos>>8;
10651 1330 bool empty = pgn==255;
10652
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1330 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1330 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
10653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1330 times.
1330 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
10654
1/2
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
1330 if(!pg)
10655 {
10656 wpos = 255; //set to nothingness
10657 return;
10658 }
10659
10660
4/6
✓ Branch 0 taken 1309 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
1330 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
10661
1/6
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1330 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
10662
1/6
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1330 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
10663 1330 auto temp = pg->movepos_legacy(SEL_VERIFY_LEFT, wpos, fp1, fp2, fp3);
10664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1330 times.
1330 if((temp&0xFF) == 0xFF)
10665 BTNwpn = -1;
10666 1330 else BTNwpn = pg->get_item_pos(temp>>8);
10667
2/2
✓ Branch 0 taken 1328 times.
✓ Branch 1 taken 2 times.
1330 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
10668 1330 wpos = temp;
10669 1330 }
10670 // A routine used exclusively by startwpn,
10671 // to switch Hero's weapon if his current weapon (bombs) was depleted.
10672 1379 void HeroClass::deselectbombs(int32_t super)
10673 {
10674
6/10
✓ Branch 0 taken 1347 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 1347 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1347 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1347 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 1347 times.
1379 if ( get_qr(qr_NEVERDISABLEAMMOONSUBSCREEN) || itemsbuf[game->forced_awpn].type == itype_bomb || itemsbuf[game->forced_bwpn].type == itype_bomb || itemsbuf[game->forced_xwpn].type == itype_bomb || itemsbuf[game->forced_ywpn].type == itype_bomb) return;
10675
4/6
✓ Branch 0 taken 1330 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 1330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1330 times.
✗ Branch 5 not taken.
1347 if(getItemFamily(itemsbuf,Bwpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Bwpn==directWpn))
10676 {
10677
1/2
✓ Branch 0 taken 1330 times.
✗ Branch 1 not taken.
1330 if(!new_subscreen_active)
10678 return;
10679
4/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1309 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1330 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1330 times.
1330 deselectbombsWPN(game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
10680 1330 }
10681
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Xwpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Xwpn==directWpn))
10682 {
10683 if(!new_subscreen_active)
10684 return;
10685 deselectbombsWPN(game->xwpn, Xwpn, directItemX, COND_AWPN, COND_BWPN, COND_YWPN);
10686 }
10687
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Ywpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Ywpn==directWpn))
10688 {
10689 if(!new_subscreen_active)
10690 return;
10691 deselectbombsWPN(game->ywpn, Ywpn, directItemY, COND_AWPN, COND_XWPN, COND_BWPN);
10692 }
10693
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17 else if (getItemFamily(itemsbuf,Awpn)==(super? itype_sbomb : itype_bomb) && (directWpn<0 || Awpn==directWpn))
10694 {
10695 if(!new_subscreen_active)
10696 return;
10697 deselectbombsWPN(game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
10698 }
10699 1379 }
10700
10701 int32_t potion_life=0;
10702 int32_t potion_magic=0;
10703
10704 13697855 bool HeroClass::onWater(bool drownonly)
10705 {
10706 13697855 int32_t water = 0;
10707 13697855 int32_t types[4] = {0};
10708 13697855 int32_t x1 = x+4, x2 = x+11,
10709 13697855 y1 = y+9, y2 = y+15;
10710
2/2
✓ Branch 0 taken 1111231 times.
✓ Branch 1 taken 12586624 times.
13697855 if (get_qr(qr_SMARTER_WATER))
10711 {
10712
4/4
✓ Branch 0 taken 10733 times.
✓ Branch 1 taken 1100498 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 8349 times.
1119602 if (iswaterex_z3(0, -1, x1, y1, true, false) &&
10713
2/2
✓ Branch 0 taken 9619 times.
✓ Branch 1 taken 1114 times.
10733 iswaterex_z3(0, -1, x1, y2, true, false) &&
10714
2/2
✓ Branch 0 taken 8371 times.
✓ Branch 1 taken 1248 times.
9619 iswaterex_z3(0, -1, x2, y1, true, false) &&
10715 8371 iswaterex_z3(0, -1, x2, y2, true, false)) water = iswaterex_z3(0, -1, (x2+x1)/2,(y2+y1)/2, true, false);
10716 1111231 }
10717 else
10718 {
10719 12586624 types[0] = COMBOTYPE(x1,y1);
10720
10721
2/2
✓ Branch 0 taken 12463002 times.
✓ Branch 1 taken 123622 times.
12586624 if(MAPFFCOMBO(x1,y1))
10722 123622 types[0] = FFCOMBOTYPE(x1,y1);
10723
10724 12586624 types[1] = COMBOTYPE(x1,y2);
10725
10726
2/2
✓ Branch 0 taken 12477770 times.
✓ Branch 1 taken 108854 times.
12586624 if(MAPFFCOMBO(x1,y2))
10727 108854 types[1] = FFCOMBOTYPE(x1,y2);
10728
10729 12586624 types[2] = COMBOTYPE(x2,y1);
10730
10731
2/2
✓ Branch 0 taken 12461789 times.
✓ Branch 1 taken 124835 times.
12586624 if(MAPFFCOMBO(x2,y1))
10732 124835 types[2] = FFCOMBOTYPE(x2,y1);
10733
10734 12586624 types[3] = COMBOTYPE(x2,y2);
10735
10736
2/2
✓ Branch 0 taken 12474638 times.
✓ Branch 1 taken 111986 times.
12586624 if(MAPFFCOMBO(x2,y2))
10737 111986 types[3] = FFCOMBOTYPE(x2,y2);
10738
10739 12586624 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
10740
2/2
✓ Branch 0 taken 12468344 times.
✓ Branch 1 taken 118280 times.
12586624 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
10741 118280 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
10742
10743
5/6
✓ Branch 0 taken 223094 times.
✓ Branch 1 taken 12363530 times.
✓ Branch 2 taken 214289 times.
✓ Branch 3 taken 8805 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 205928 times.
12792552 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
10744
4/4
✓ Branch 0 taken 206169 times.
✓ Branch 1 taken 8120 times.
✓ Branch 2 taken 205928 times.
✓ Branch 3 taken 241 times.
214289 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
10745 205928 water = typec;
10746 }
10747
2/2
✓ Branch 0 taken 13483578 times.
✓ Branch 1 taken 214277 times.
13697855 if(water > 0)
10748 {
10749
1/2
✓ Branch 0 taken 214277 times.
✗ Branch 1 not taken.
214277 if(!drownonly) return true;
10750
7/8
✓ Branch 0 taken 139216 times.
✓ Branch 1 taken 75061 times.
✓ Branch 2 taken 139213 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 2249 times.
✓ Branch 5 taken 136964 times.
✓ Branch 6 taken 2249 times.
✗ Branch 7 not taken.
214277 if(current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & item_flag3)))
10751 {
10752 75064 return true;
10753 }
10754 139213 }
10755 13622791 return false;
10756 13697855 }
10757
10758 bool HeroClass::mirrorBonk()
10759 {
10760 zfix tx = x, ty = y, tz = z;
10761 WalkflagInfo info = walkflag(x,y+(bigHitbox?0:8),2,up);
10762 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8));
10763 execute(info);
10764 bool fail = info.isUnwalkable();
10765
10766 if(!fail) //not solid, but check for water/pits...
10767 {
10768 if(onWater(true))
10769 fail = true;
10770 if(pitslide() || fallclk)
10771 fail = true;
10772 fallclk = 0;
10773 }
10774 x = tx; y = ty; z = tz;
10775 return fail;
10776 }
10777
10778 void HeroClass::doMirror(int32_t mirrorid)
10779 {
10780 if(z > 0 || fakez > 0) return; //No mirror in air
10781 if(mirrorid < 0)
10782 mirrorid = current_item_id(itype_mirror);
10783 if(mirrorid < 0) return;
10784 if (on_cooldown(mirrorid)) return;
10785
10786 if((hero_scr->flags9&fDISABLE_MIRROR) || !(checkbunny(mirrorid) && checkmagiccost(mirrorid)))
10787 {
10788 item_error();
10789 return;
10790 }
10791 static const int32_t sens = 4; //sensitivity of 'No Mirror' combos (0 most, 8 least)
10792 rpos_t rposes[] = {COMBOPOS_REGION_B(x+sens,y+sens), COMBOPOS_REGION_B(x+sens,y+15-sens),
10793 COMBOPOS_REGION_B(x+15-sens,y+sens), COMBOPOS_REGION_B(x+15-sens,y+15-sens)};
10794 for(auto rpos : rposes)
10795 {
10796 if (rpos == rpos_t::None)
10797 continue;
10798
10799 if(HASFLAG_ANY(mfNOMIRROR, rpos)) //"No Mirror" flag touching the player
10800 {
10801 item_error();
10802 return;
10803 }
10804 }
10805
10806 itemdata const& mirror = itemsbuf[mirrorid];
10807 if(DMaps[cur_dmap].flags & dmfMIRRORCONTINUE)
10808 {
10809 paymagiccost(mirrorid);
10810 start_cooldown(mirrorid);
10811 if(mirror.usesound2) sfx(mirror.usesound2);
10812
10813 doWarpEffect(mirror.misc2, true);
10814 if(mirror.flags & item_flag2) //Act as F6->Continue
10815 {
10816 Quit = qCONT;
10817 skipcont = 1;
10818 }
10819 else //Act as Divine Escape
10820 {
10821 int32_t div_prot_temp=div_prot_item;
10822 restart_level();
10823 div_prot_item=div_prot_temp;
10824 magicitem=-1;
10825 magiccastclk=0;
10826 if ( Hero.getDontDraw() < 2 ) { Hero.setDontDraw(0); }
10827 }
10828 }
10829 else
10830 {
10831 int32_t destdmap = DMaps[cur_dmap].mirrorDMap;
10832 int32_t offscr = cur_screen - DMaps[cur_dmap].xoff;
10833 if(destdmap < 0)
10834 return;
10835 int32_t destscr = DMaps[destdmap].xoff + offscr;
10836 if((offscr%16 != destscr%16) || unsigned(destscr) >= 0x80)
10837 return;
10838 paymagiccost(mirrorid);
10839 start_cooldown(mirrorid);
10840
10841 //Store some values to restore if 'warp fails'
10842 int32_t tLastEntrance = lastentrance,
10843 tLastEntranceDMap = lastentrance_dmap,
10844 tContScr = game->get_continue_scrn(),
10845 tContDMap = game->get_continue_dmap(),
10846 tPortalDMap = game->saved_mirror_portal.srcdmap;
10847 int32_t sourcescr = cur_screen, sourcedmap = cur_dmap;
10848 zfix tx = x, ty = y, tz = z;
10849 game->saved_mirror_portal.srcdmap = -1;
10850 action = none; FFCore.setHeroAction(none);
10851
10852 //Warp to new dmap
10853 FFCore.warp_player(wtIWARP, destdmap, destscr, -1, -1, mirror.misc1,
10854 mirror.usesound, 0, -1);
10855
10856 //Check for valid landing location
10857 if(mirrorBonk()) //Invalid landing, warp back!
10858 {
10859 action = none; FFCore.setHeroAction(none);
10860 lastentrance = tLastEntrance;
10861 lastentrance_dmap = tLastEntranceDMap;
10862 game->set_continue_scrn(tContScr);
10863 game->set_continue_dmap(tContDMap);
10864 x = tx;
10865 y = ty;
10866 z = tz;
10867 game->saved_mirror_portal.srcdmap = tPortalDMap;
10868 FFCore.warp_player(wtIWARP, sourcedmap, sourcescr, -1, -1, mirror.misc1,
10869 mirror.usesound, 0, -1);
10870 }
10871 else if(mirror.flags & item_flag1) //Place portal!
10872 {
10873 //Place the portal
10874 game->set_portal(sourcedmap, destdmap, offscr, x.getZLong(), y.getZLong(), mirror.usesound, mirror.misc1, mirror.wpn);
10875 //Since it was placed after loading this screen, load the portal object now
10876 game->load_portal();
10877 //Don't immediately trigger the warp back
10878 mirror_portal.prox_active = false;
10879
10880 //Set continue point
10881 if(cur_dmap != game->get_continue_dmap())
10882 {
10883 game->set_continue_scrn(DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff);
10884 }
10885 game->set_continue_dmap(cur_dmap);
10886 lastentrance_dmap = cur_dmap;
10887 lastentrance = game->get_continue_scrn();
10888 }
10889 }
10890 }
10891
10892 14307785 void HeroClass::handle_passive_buttons()
10893 {
10894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14307785 times.
14307785 if(no_control()) return;
10895 14307785 do_liftglove(-1,true);
10896 14307785 do_jump(-1,true);
10897 14307785 }
10898
10899 3777 void HeroClass::land_on_ground()
10900 {
10901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3777 times.
3777 if (fakez<0) fakez = 0;
10902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3777 times.
3777 if (z<0) z = 0;
10903
10904 3777 bool played_land_sfx = false;
10905
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 3716 times.
3777 if(get_qr(qr_OLD_LANDING_SFX))
10906 {
10907
9/10
✓ Branch 0 taken 3307 times.
✓ Branch 1 taken 409 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 399 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3694 times.
✓ Branch 9 taken 22 times.
4125 if(!sideview_mode() && ((iswaterex_z3(MAPCOMBO(x,y+8), -1, x, y+8, true, false) && ladderx<=0 && laddery<=0) || COMBOTYPE(x,y+8)==cSHALLOWWATER))
10908 22 sfx(WAV_ZN1SPLASH,x.getInt());
10909 3716 played_land_sfx = true;
10910 3716 }
10911
10912 3777 auto rpos = COMBOPOS_REGION_B(x+8, y+(sideview_mode()?16:12));
10913
2/2
✓ Branch 0 taken 3770 times.
✓ Branch 1 taken 26397 times.
30167 for (int q = 0; q < 7; ++q)
10914 {
10915
2/2
✓ Branch 0 taken 26390 times.
✓ Branch 1 taken 7 times.
26397 if (rpos == rpos_t::None) break;
10916
10917 26390 auto rpos_handle = get_rpos_handle(rpos, q);
10918 26390 auto& cmb = rpos_handle.combo();
10919 26390 byte csfx = cmb.sfx_landing;
10920
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 26363 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
26390 if (csfx && !get_qr(qr_OLD_LANDING_SFX))
10921 {
10922 sfx(csfx, x.getInt());
10923 played_land_sfx = true;
10924 }
10925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26390 times.
26602 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
10926 212 return trig.trigger_flags.get(TRIGFLAG_PLAYERLANDHERE);
10927 });
10928 26390 }
10929
10930
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 3716 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
3777 if(!played_land_sfx && QMisc.miscsfx[sfxHERO_LANDS])
10931 sfx(QMisc.miscsfx[sfxHERO_LANDS], x.getInt());
10932
10933
10934 1852129 for_some_rpos([&](const rpos_handle_t& rpos_handle) {
10935
1/2
✓ Branch 0 taken 1848352 times.
✗ Branch 1 not taken.
1872908 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
10936 24556 return trig.trigger_flags.get(TRIGFLAG_PLAYERLANDANYWHERE);
10937 });
10938
10939 1848352 return true;
10940 });
10941 117695 for_some_ffcs([&](const ffc_handle_t& ffc_handle) {
10942
1/2
✓ Branch 0 taken 113918 times.
✗ Branch 1 not taken.
113918 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
10943 return trig.trigger_flags.get(TRIGFLAG_PLAYERLANDANYWHERE);
10944 });
10945
10946 113918 return true;
10947 });
10948 3777 }
10949
10950 static bool did_passive_jump = false;
10951 14308154 bool HeroClass::do_jump(int32_t jumpid, bool passive)
10952 {
10953
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 14307785 times.
14308154 if(passive) did_passive_jump = false;
10954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 369 times.
369 else if(did_passive_jump) return false; //don't jump twice in the same frame
10955
10956
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14308154 times.
14308154 if (on_cooldown(jumpid)) return false;
10957
2/2
✓ Branch 0 taken 610313 times.
✓ Branch 1 taken 13697841 times.
14308154 if(nomove_action(action)) return false; //can't jump while ex. drowning
10958
2/2
✓ Branch 0 taken 75064 times.
✓ Branch 1 taken 13622777 times.
13697841 if(onWater(true)) return false; //Don't allow jumping off of water frame-perfectly...
10959
10960
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 13622410 times.
13622777 if(jumpid < 0)
10961 13622410 jumpid = current_item_id(itype_rocs,true,true);
10962
10963
2/2
✓ Branch 0 taken 13235632 times.
✓ Branch 1 taken 387145 times.
13622777 if(unsigned(jumpid) >= MAXITEMS) return false;
10964
4/4
✓ Branch 0 taken 385918 times.
✓ Branch 1 taken 1227 times.
✓ Branch 2 taken 1935 times.
✓ Branch 3 taken 383983 times.
387145 if(inlikelike || charging) return false;
10965
1/2
✓ Branch 0 taken 383983 times.
✗ Branch 1 not taken.
383983 if(!checkitem_jinx(jumpid)) return false;
10966
10967 383983 itemdata const& itm = itemsbuf[jumpid];
10968
10969 383983 bool standing = isStanding(true);
10970
3/4
✓ Branch 0 taken 370060 times.
✓ Branch 1 taken 13923 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13923 times.
383983 bool coyotejump = !standing && coyotetime < (zc_min(65535,itm.misc5));
10971
4/6
✓ Branch 0 taken 383983 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13923 times.
✓ Branch 3 taken 370060 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 13923 times.
383983 if(!(coyotejump || standing || extra_jump_count < itm.misc1)) return false;
10972
2/4
✓ Branch 0 taken 370060 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 370060 times.
370060 if(!(checkbunny(jumpid) && checkmagiccost(jumpid)))
10973 {
10974 item_error();
10975 return false;
10976 }
10977
10978 370060 byte intbtn = byte(itm.misc2&0xFF);
10979
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 369708 times.
370060 if(passive)
10980 {
10981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 369708 times.
369708 if(!getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK | INPUT_PEEK))
10982 369708 return false; //not pressed
10983 }
10984
10985 352 paymagiccost(jumpid);
10986 352 start_cooldown(jumpid);
10987
10988
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if (itm.flags & item_flag6) // delayed effect on release, store the jump id
10989 {
10990 current_rocs_jump_id = jumpid;
10991 released_jump_button = false;
10992 }
10993
10994
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(!standing)
10995 {
10996 ++extra_jump_count;
10997 fall = 0;
10998 fakefall = 0;
10999 if(hoverclk > 0)
11000 hoverclk = -hoverclk;
11001 }
11002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352 times.
352 if(itm.flags & item_flag1)
11003 setFall(fall - itm.power);
11004 352 else setFall(fall - (FEATHERJUMP*(itm.power+2)));
11005 352 coyotetime = 65535; //jumped, so no coyotetime
11006 352 setOnSideviewLadder(false);
11007
11008 // Reset the ladder, unless on an unwalkable combo
11009
6/10
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 352 times.
✗ Branch 9 not taken.
352 if((ladderx || laddery) && !(_walkflag(ladderx,laddery,0,STANDING_Z_STATE)))
11010 reset_ladder();
11011
11012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 352 times.
352 if(itm.usesound)
11013 352 sfx(itm.usesound,pan(x));
11014
11015
1/2
✓ Branch 0 taken 352 times.
✗ Branch 1 not taken.
352 if(passive)
11016 {
11017 did_passive_jump = true;
11018 getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK); //eat buttons
11019 }
11020 352 return true;
11021 14308154 }
11022 11720 void HeroClass::drop_liftwpn()
11023 {
11024
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11719 times.
11720 if(!lift_wpn) return;
11025
11026 1 handle_lift(false); //sets position properly, accounting for large weapons
11027
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 int liftid = last_lift_id ? *last_lift_id : current_item_id(itype_liftglove,true,true);
11028 1 itemdata const& glove = itemsbuf[liftid];
11029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(isSideViewGravity())
11030 {
11031 lift_wpn->moveflags |= move_no_fake_z;
11032 }
11033 else
11034 {
11035 1 auto lheight = liftheight+z+fakez;
11036
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(glove.flags & item_flag1)
11037 {
11038 lift_wpn->z = 0;
11039 lift_wpn->fakez = lheight;
11040 lift_wpn->moveflags |= move_no_real_z;
11041 }
11042 else
11043 {
11044 1 lift_wpn->z = lheight;
11045 1 lift_wpn->moveflags |= move_no_fake_z;
11046 }
11047 }
11048 1 lift_wpn->dir = dir;
11049 1 lift_wpn->step = 0;
11050 1 lift_wpn->fakefall = 0;
11051 1 lift_wpn->fall = 0;
11052 1 Lwpns.add(lift_wpn);
11053 1 lift_wpn = nullptr;
11054 11720 }
11055 14307785 void HeroClass::do_liftglove(int32_t liftid, bool passive)
11056 {
11057
2/2
✓ Branch 0 taken 10406 times.
✓ Branch 1 taken 14297379 times.
14307785 if(!lift_wpn)
11058 14297379 last_lift_id.reset();
11059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14307785 times.
14307785 if(liftid < 0)
11060 {
11061
4/4
✓ Branch 0 taken 9569 times.
✓ Branch 1 taken 14298216 times.
✓ Branch 2 taken 689 times.
✓ Branch 3 taken 8880 times.
14307785 if(last_lift_id && can_lift(*last_lift_id))
11062 8880 liftid = *last_lift_id;
11063 14298905 else liftid = current_item_id(itype_liftglove,true,true);
11064 14307785 }
11065
2/2
✓ Branch 0 taken 362622 times.
✓ Branch 1 taken 13945163 times.
14307785 if(!can_lift(liftid)) return;
11066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362622 times.
362622 if (on_cooldown(liftid)) return;
11067 362622 itemdata const& glove = itemsbuf[liftid];
11068 362622 byte intbtn = byte(glove.misc1&0xFF);
11069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 362622 times.
362622 if(passive)
11070 {
11071
2/2
✓ Branch 0 taken 2248 times.
✓ Branch 1 taken 360374 times.
362622 if(!getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK | INPUT_PEEK))
11072 360374 return; //not pressed
11073 2248 }
11074
11075 2248 bool had_weapon = lift_wpn;
11076
11077
3/4
✓ Branch 0 taken 2187 times.
✓ Branch 1 taken 61 times.
✓ Branch 2 taken 2187 times.
✗ Branch 3 not taken.
4435 if(!(had_weapon || //Allow throwing while bunnied/don't charge magic for throwing
11078
1/2
✓ Branch 0 taken 2187 times.
✗ Branch 1 not taken.
2187 (checkbunny(liftid) && checkmagiccost(liftid))))
11079 {
11080 item_error();
11081 return;
11082 }
11083
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2248 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2248 if(glove.script!=0 && (FFCore.doscript(ScriptType::Item, liftid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
11084 return;
11085
11086 2248 bool paidmagic = had_weapon; //don't pay to throw, only to lift
11087
1/2
✓ Branch 0 taken 2248 times.
✗ Branch 1 not taken.
2248 if(glove.script)
11088 {
11089 if(!paidmagic)
11090 {
11091 paidmagic = true;
11092 paymagiccost(liftid);
11093 }
11094
11095 int i = liftid;
11096 FFCore.reset_script_engine_data(ScriptType::Item, i);
11097 ZScriptVersion::RunScript(ScriptType::Item, glove.script, i);
11098 FFCore.deallocateAllScriptOwned(ScriptType::Item,i);
11099
11100 bool has_weapon = lift_wpn;
11101 if(has_weapon != had_weapon) //Item action script changed the lift information
11102 {
11103 if(passive)
11104 {
11105 getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK); //eat buttons
11106 }
11107 return;
11108 }
11109 }
11110
11111
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 2187 times.
2248 if(lift_wpn)
11112 {
11113
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(!paidmagic)
11114 {
11115 paidmagic = true;
11116 paymagiccost(liftid);
11117 }
11118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(!liftclk)
11119 {
11120 //Throw the weapon!
11121 //hero's direction and position
11122 61 handle_lift(false); //sets position properly, accounting for large weapons
11123
11124 61 lift_wpn->dir = dir;
11125
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(lift_wpn->angular)
11126 lift_wpn->angle = WrapAngle(DirToRadians(dir));
11127
11128 61 lift_wpn->doAutoRotate(false, true);
11129 //Configured throw speed in both axes
11130 61 auto basestep = glove.misc2;
11131 61 lift_wpn->step = zfix(basestep)/100;
11132
11133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(isSideViewGravity())
11134 {
11135 lift_wpn->fall = -glove.misc3;
11136 switch(dir)
11137 {
11138 case left: case right:
11139 break; //nothing special for sideways
11140 case up: //step converts to upwards fall
11141 lift_wpn->fall -= basestep;
11142 lift_wpn->step = 0;
11143 break;
11144 case down: //step converts into straight down fall
11145 lift_wpn->fall = zc_min(basestep,lift_wpn->get_terminalv());
11146 lift_wpn->step = 0;
11147 break;
11148 }
11149 lift_wpn->moveflags |= move_no_fake_z;
11150 }
11151 else
11152 {
11153 61 auto lheight = liftheight+z+fakez;
11154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(glove.flags & item_flag1)
11155 {
11156 lift_wpn->z = 0;
11157 lift_wpn->fakez = lheight;
11158 lift_wpn->fakefall = -glove.misc3;
11159 lift_wpn->moveflags |= move_no_real_z;
11160 }
11161 else
11162 {
11163 61 lift_wpn->z = lheight;
11164 61 lift_wpn->fall = -glove.misc3;
11165 61 lift_wpn->moveflags |= move_no_fake_z;
11166 }
11167 }
11168 61 Lwpns.add(lift_wpn);
11169 61 lift_wpn = nullptr;
11170 61 last_lift_id.reset();
11171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(glove.usesound2)
11172 61 sfx(glove.usesound2,pan(x));
11173 61 }
11174 else last_lift_id = liftid;
11175
11176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(passive)
11177 {
11178 61 getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK); //eat buttons
11179 61 }
11180 61 start_cooldown(liftid);
11181 61 return;
11182 }
11183
11184 2187 bool lifted = false;
11185 //Check for a liftable weapon
11186 //if(!lifted)
11187 {
11188 2187 zfix hx, hy, hw, hh;
11189
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 580 times.
✓ Branch 3 taken 670 times.
✓ Branch 4 taken 597 times.
2187 switch(dir)
11190 {
11191 case up:
11192 340 hx = x;
11193 340 hy = y-8;
11194 340 hw = 16;
11195 340 hh = bigHitbox ? 8 : 16;
11196 340 break;
11197 case down:
11198 580 hx = x;
11199 580 hy = y+16;
11200 580 hw = 16;
11201 580 hh = 8;
11202 580 break;
11203 case left:
11204 670 hx = x-8;
11205 670 hy = y;
11206 670 hw = 8;
11207 670 hh = 16;
11208 670 break;
11209 case right:
11210 597 hx = x+16;
11211 597 hy = y;
11212 597 hw = 8;
11213 597 hh = 16;
11214 597 break;
11215 }
11216
2/2
✓ Branch 0 taken 2185 times.
✓ Branch 1 taken 113 times.
2298 for(int32_t q = 0; q < Lwpns.Count(); ++q)
11217 {
11218 113 weapon* w = (weapon*)Lwpns.spr(q);
11219
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
113 if((w->lift_level && w->lift_level <= glove.level))
11220 {
11221 7 auto tmpflags = w->misc_wflags;
11222 7 w->misc_wflags &= ~WFLAG_NO_COLL_WHEN_STILL;
11223 7 bool hit = w->hit(hx,hy,0,hw,hh,1);
11224 7 w->misc_wflags = tmpflags;
11225
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(!hit)
11226 5 continue;
11227
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(glove.usesound)
11228 2 sfx(glove.usesound,pan(x));
11229 2 lift(w, w->lift_time, w->lift_height);
11230 2 Lwpns.remove(w);
11231 2 lifted = true;
11232 2 break;
11233 }
11234 106 }
11235 }
11236
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2185 times.
2187 if(!lifted) //Check for a liftable combo
11237 {
11238 2185 zfix bx, by;
11239 2185 zfix bx2, by2;
11240
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 580 times.
✓ Branch 3 taken 670 times.
✓ Branch 4 taken 595 times.
2185 switch(dir)
11241 {
11242 case up:
11243 340 by = y + (bigHitbox ? -2 : 6);
11244 340 by2 = by;
11245 340 bx = x + 4;
11246 340 bx2 = bx + 8;
11247 340 break;
11248 case down:
11249 580 by = y + 17;
11250 580 by2 = by;
11251 580 bx = x + 4;
11252 580 bx2 = bx + 8;
11253 580 break;
11254 case left:
11255 670 by = y + (bigHitbox ? 0 : 8);
11256 670 by2 = y + 8;
11257 670 bx = x - 2;
11258 670 bx2 = x - 2;
11259 670 break;
11260 case right:
11261 595 by = y + (bigHitbox ? 0 : 8);
11262 595 by2 = y + 8;
11263 595 bx = x + 17;
11264 595 bx2 = x + 17;
11265 595 break;
11266 }
11267 2185 rpos_t rpos = COMBOPOS_REGION_B(bx, by);
11268 2185 rpos_t rpos2 = COMBOPOS_REGION_B(bx2, by2);
11269
11270
2/2
✓ Branch 0 taken 2142 times.
✓ Branch 1 taken 15271 times.
17413 for(auto lyr = 6; lyr >= 0; --lyr)
11271 {
11272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15271 times.
15271 if(rpos != rpos_t::None)
11273 {
11274 15271 auto rpos_handle = get_rpos_handle(rpos, lyr);
11275 15271 auto& cmb = rpos_handle.combo();
11276
2/2
✓ Branch 0 taken 15231 times.
✓ Branch 1 taken 40 times.
15271 if(cmb.liftflags & LF_LIFTABLE)
11277 {
11278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(do_lift_combo(rpos_handle,liftid))
11279 {
11280 40 lifted = true;
11281 40 break;
11282 }
11283 }
11284 15231 }
11285
3/4
✓ Branch 0 taken 2139 times.
✓ Branch 1 taken 13092 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2139 times.
15231 if(rpos != rpos2 && rpos2 != rpos_t::None)
11286 {
11287 2139 auto rpos_handle_2 = get_rpos_handle(rpos2, lyr);
11288 2139 newcombo const& cmb2 = combobuf[rpos_handle_2.data()];
11289
2/2
✓ Branch 0 taken 2136 times.
✓ Branch 1 taken 3 times.
2139 if(cmb2.liftflags & LF_LIFTABLE)
11290 {
11291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(do_lift_combo(rpos_handle_2,liftid))
11292 {
11293 3 lifted = true;
11294 3 break;
11295 }
11296 }
11297 2136 }
11298 15228 }
11299 2185 }
11300
11301
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 2142 times.
2187 if(!lifted)
11302 {
11303 2142 last_lift_id.reset();
11304 2142 return;
11305 }
11306 45 last_lift_id = liftid;
11307
11308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!paidmagic)
11309 {
11310 45 paidmagic = true;
11311 45 paymagiccost(liftid);
11312 45 }
11313 45 start_cooldown(liftid);
11314 45 set_liftflags(liftid);
11315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(passive)
11316 45 getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK); //eat buttons
11317 45 return;
11318 14307785 }
11319 21661 void HeroClass::handle_lift(bool dec)
11320 {
11321
1/2
✓ Branch 0 taken 21661 times.
✗ Branch 1 not taken.
21661 if(lift_wpn)
11322 {
11323 21661 lift_wpn->fakez = 0;
11324 21661 lift_wpn->dir = dir;
11325 21661 }
11326 else liftclk = 0;
11327
11328
2/2
✓ Branch 0 taken 19896 times.
✓ Branch 1 taken 1765 times.
21661 if(liftclk <= (dec?1:0))
11329 {
11330 19896 liftclk = 0;
11331 19896 tliftclk = 0;
11332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19896 times.
19896 if(lift_wpn)
11333 {
11334
2/4
✓ Branch 0 taken 19896 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 19896 times.
19896 if(lift_wpn->txsz > 1 || lift_wpn->tysz > 1)
11335 {
11336 lift_wpn->x = x+8 - (lift_wpn->txsz*8);
11337 lift_wpn->y = y+8 - (lift_wpn->tysz*8);
11338 }
11339 else
11340 {
11341 19896 lift_wpn->x = x;
11342 19896 lift_wpn->y = y;
11343 }
11344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19896 times.
19896 if(isSideViewGravity())
11345 lift_wpn->y -= liftheight;
11346 19896 else lift_wpn->z = liftheight;
11347 19896 }
11348
2/2
✓ Branch 0 taken 19834 times.
✓ Branch 1 taken 62 times.
19896 if(action == lifting)
11349 {
11350 62 action = none; FFCore.setHeroAction(none);
11351 62 }
11352 19896 return;
11353 }
11354
2/2
✓ Branch 0 taken 891 times.
✓ Branch 1 taken 874 times.
1765 if(dec) --liftclk;
11355 double xdist, ydist;
11356 1765 double perc = (liftclk/double(tliftclk));
11357
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
✓ Branch 2 taken 255 times.
✓ Branch 3 taken 514 times.
✓ Branch 4 taken 678 times.
1765 switch(dir)
11358 {
11359 case up:
11360 {
11361 318 xdist = 0;
11362 318 ydist = -16;
11363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
318 if(lift_wpn->txsz > 1)
11364 {
11365 xdist = -((lift_wpn->txsz*8)-8);
11366 }
11367 318 else xdist = 0;
11368
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(lift_wpn->tysz > 1)
11369 {
11370 ydist = -(lift_wpn->tysz*16);
11371 }
11372 318 ydist *= perc;
11373 318 break;
11374 }
11375 case down:
11376 {
11377 255 xdist = 0;
11378 255 ydist = 16;
11379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 if(lift_wpn->txsz > 1)
11380 {
11381 xdist = -((lift_wpn->txsz*8)-8);
11382 }
11383 255 else xdist = 0;
11384 255 ydist *= perc;
11385 255 break;
11386 }
11387 case left:
11388 {
11389 514 xdist = -16;
11390 514 ydist = 0;
11391
1/2
✓ Branch 0 taken 514 times.
✗ Branch 1 not taken.
514 if(lift_wpn->txsz > 1)
11392 {
11393 xdist = -(lift_wpn->txsz*16);
11394 }
11395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 514 times.
514 if(lift_wpn->tysz > 1)
11396 {
11397 ydist = -((lift_wpn->tysz*8)-8);
11398 }
11399 514 else ydist = 0;
11400 514 xdist *= perc;
11401 514 break;
11402 }
11403 case right:
11404 {
11405 678 xdist = 16;
11406 678 ydist = 0;
11407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 678 times.
678 if(lift_wpn->tysz > 1)
11408 {
11409 ydist = -((lift_wpn->tysz*8)-8);
11410 }
11411 678 else ydist = 0;
11412 678 xdist *= perc;
11413 678 break;
11414 }
11415 }
11416
11417 1765 lift_wpn->x = x + xdist;
11418 1765 lift_wpn->y = y + ydist;
11419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1765 times.
1765 if(isSideViewGravity())
11420 lift_wpn->y -= liftheight*(1.0-perc);
11421 1765 else lift_wpn->z = liftheight*(1.0-perc);
11422 21661 }
11423 14317397 bool HeroClass::can_lift(int32_t gloveid)
11424 {
11425
2/2
✓ Branch 0 taken 13881883 times.
✓ Branch 1 taken 435514 times.
14317397 if(unsigned(gloveid) >= MAXITEMS) return false;
11426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435514 times.
435514 if(lstunclock) return false;
11427
1/2
✓ Branch 0 taken 435514 times.
✗ Branch 1 not taken.
435514 if(!checkitem_jinx(gloveid)) return false;
11428 435514 itemdata const& glove = itemsbuf[gloveid];
11429
3/3
✓ Branch 0 taken 371545 times.
✓ Branch 1 taken 57216 times.
✓ Branch 2 taken 6753 times.
435514 switch(action)
11430 {
11431 case none: case walking:
11432 371545 break;
11433
11434 case swimming:
11435
1/2
✓ Branch 0 taken 6753 times.
✗ Branch 1 not taken.
6753 if(glove.flags & item_flag2)
11436 break;
11437 6753 return false;
11438
11439 default:
11440 57216 return false;
11441 }
11442 371545 return true;
11443 14317397 }
11444 62 void HeroClass::lift(weapon* w, byte timer, zfix height)
11445 {
11446 62 lift_wpn = w;
11447 62 liftclk = timer;
11448 62 tliftclk = timer;
11449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
62 if(height < 0)
11450 liftheight = 0;
11451 62 else liftheight = height;
11452 62 }
11453
11454 15406 void HeroClass::check_on_hit() // Called when the player is hit
11455 {
11456
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 15395 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
15406 if(lift_wpn && (liftflags & LIFTFL_DROP_ON_HIT))
11457 drop_liftwpn();
11458 15406 }
11459
11460 137 void HeroClass::doSwitchHook(byte style)
11461 {
11462 137 hs_switcher = true;
11463 137 pull_hero = true;
11464 //{ Load hook weapons, set them to obey special drawing
11465 137 weapon *w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot)),
11466 137 *hw = (weapon*)Lwpns.spr(Lwpns.idFirst(wHSHandle));
11467
11468
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
137 if(w)
11469 1 w->switch_hooked = true;
11470
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 1 times.
137 if(hw)
11471 1 hw->switch_hooked = true;
11472
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 137 times.
142 for(int32_t j=0; j<chainlinks.Count(); j++)
11473 {
11474 5 chainlinks.spr(j)->switch_hooked = true;
11475 5 }
11476 //}
11477 137 rpos_t plrpos = COMBOPOS_REGION_B(x+8, y+8);
11478
3/4
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
137 if(hooked_comborpos != rpos_t::None && plrpos != rpos_t::None)
11479 {
11480
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
11481 132 hooked_layerbits = 0;
11482
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(auto q = 0; q < 7; ++q)
11483 924 hooked_undercombos[q] = -1;
11484
11485 132 int target_pos = RPOS_TO_POS(hooked_comborpos);
11486 132 int player_pos = RPOS_TO_POS(plrpos);
11487
11488
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 132 times.
1056 for(auto q = max_layer; q > -1; --q)
11489 {
11490 924 auto target_pos_handle = get_rpos_handle(hooked_comborpos, q);
11491 924 auto player_pos_handle = get_rpos_handle(plrpos, q);
11492
11493 924 mapscr* player_scr = player_pos_handle.scr;
11494 924 mapscr* target_scr = target_pos_handle.scr;
11495
11496 924 newcombo const& cmb = combobuf[target_scr->data[target_pos]];
11497 924 newcombo const& comb2 = combobuf[player_scr->data[player_pos]];
11498 924 int32_t fl1 = target_scr->sflag[target_pos],
11499 924 fl2 = player_scr->sflag[player_pos];
11500 924 bool isPush = false;
11501
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 132 times.
924 if(isSwitchHookable(cmb))
11502 {
11503
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.type == cSWITCHHOOK)
11504 {
11505
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
132 if((cmb.usrflags&cflag1) && player_scr->data[player_pos])
11506 continue; //don't swap with non-zero combo
11507
3/12
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 132 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 132 times.
132 if(zc_max(1,itemsbuf[(w && w->parentitem>-1) ? w->parentitem : current_item_id(itype_switchhook)].level) < cmb.attribytes[0])
11508 continue; //too low a switchhook level
11509 132 hooked_layerbits |= 1<<q; //Swapping
11510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(cmb.usrflags&cflag3)
11511 {
11512 if(cmb.usrflags&cflag6)
11513 {
11514 hooked_undercombos[q] = target_scr->data[target_pos]+1;
11515 hooked_undercombos[q+7] = target_scr->cset[target_pos];
11516 }
11517 else
11518 {
11519 hooked_undercombos[q] = target_scr->undercombo;
11520 hooked_undercombos[q+7] = target_scr->undercset;
11521 }
11522 }
11523 else
11524 {
11525 132 hooked_layerbits |= 1<<(q+8); //Swapping BACK
11526
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(cmb.usrflags&cflag7) //counts as 'pushblock'
11527 isPush = true;
11528 }
11529 132 }
11530 else if(isCuttableType(cmb.type))
11531 {
11532 if(isCuttableNextType(cmb.type))
11533 {
11534 hooked_undercombos[q] = target_scr->data[target_pos]+1;
11535 hooked_undercombos[q+7] = target_scr->cset[target_pos];
11536 }
11537 else
11538 {
11539 hooked_undercombos[q] = target_scr->undercombo;
11540 hooked_undercombos[q+7] = target_scr->undercset;
11541 }
11542 hooked_layerbits |= 1<<q; //Swapping
11543 }
11544 else
11545 {
11546 hooked_layerbits |= 1<<q; //Swapping
11547 hooked_layerbits |= 1<<(q+8); //Swapping BACK
11548 }
11549 132 }
11550
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 132 times.
924 if(hooked_layerbits & (1<<(q+8))) //2-way swap, check for pushblocks
11551 {
11552
3/6
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 132 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 132 times.
✗ Branch 5 not taken.
132 if((cmb.type==cPUSH_WAIT || cmb.type==cPUSH_HW || cmb.type==cPUSH_HW2)
11553 132 && hasMainGuy(target_scr->screen))
11554 {
11555 hooked_layerbits &= ~(0x101<<q); //Can't swap yet
11556 continue;
11557 }
11558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
132 if(fl1 == mfPUSHED)
11559 {
11560 hooked_layerbits &= ~(0x101<<q); //Can't swap at all, locked in place
11561 continue;
11562 }
11563
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(fl1)
11564 {
11565 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
11566 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
11567 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
11568 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
11569 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
11570 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
11571 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
11572 isPush = true;
11573 132 }
11574
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 132 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 132 times.
132 if(!isPush) switch(cmb.flag)
11575 {
11576 case mfPUSHUD: case mfPUSHUDNS: case mfPUSHUDINS:
11577 case mfPUSHLR: case mfPUSHLRNS: case mfPUSHLRINS:
11578 case mfPUSHU: case mfPUSHUNS: case mfPUSHUINS:
11579 case mfPUSHD: case mfPUSHDNS: case mfPUSHDINS:
11580 case mfPUSHL: case mfPUSHLNS: case mfPUSHLINS:
11581 case mfPUSHR: case mfPUSHRNS: case mfPUSHRINS:
11582 case mfPUSH4: case mfPUSH4NS: case mfPUSH4INS:
11583 isPush = true;
11584 132 }
11585
1/2
✓ Branch 0 taken 132 times.
✗ Branch 1 not taken.
132 if(isPush) //Check for block holes / triggers
11586 {
11587 if(comb2.flag == mfBLOCKHOLE || fl2 == mfBLOCKHOLE
11588 || comb2.flag == mfBLOCKTRIGGER || fl2 == mfBLOCKTRIGGER)
11589 {
11590 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11591 }
11592 else if(!get_qr(qr_BLOCKHOLE_SAME_ONLY))
11593 {
11594 auto maxLayer = get_qr(qr_PUSHBLOCK_LAYER_1_2) ? 2 : 0;
11595 for(auto lyr = 0; lyr < maxLayer; ++lyr)
11596 {
11597 if(lyr == q) continue;
11598 switch(player_scr->sflag[player_pos])
11599 {
11600 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
11601 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11602 lyr=7;
11603 break;
11604 }
11605 switch(combobuf[player_scr->data[player_pos]].flag)
11606 {
11607 case mfBLOCKHOLE: case mfBLOCKTRIGGER:
11608 hooked_layerbits &= ~(1<<(q+8)); //Don't swap the hole/trigger back
11609 lyr=7;
11610 break;
11611 }
11612 }
11613 }
11614 }
11615 132 }
11616 924 }
11617 132 }
11618 137 switch_hooked = true;
11619 137 switchhookstyle = style;
11620
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136 times.
✗ Branch 3 not taken.
137 switch(style)
11621 {
11622 default: case swPOOF:
11623 {
11624 1 wpndata const& spr = wpnsbuf[QMisc.sprites[sprSWITCHPOOF]];
11625
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 switchhookmaxtime = switchhookclk = zc_max(spr.frames,1) * zc_max(spr.speed,1);
11626
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(x, y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(hooked_comborpos != rpos_t::None)
11628 {
11629 auto [decx, decy] = COMBOXY_REGION(hooked_comborpos);
11630 decorations.add(new comboSprite(decx, decy, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11631 }
11632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 else if(switching_object)
11633
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 decorations.add(new comboSprite(switching_object->x, switching_object->y, dCOMBOSPRITE, 0, QMisc.sprites[sprSWITCHPOOF]));
11634 1 break;
11635 }
11636 case swFLICKER:
11637 {
11638 136 switchhookmaxtime = switchhookclk = 64;
11639 136 break;
11640 }
11641 case swRISE:
11642 {
11643 switchhookmaxtime = switchhookclk = 64;
11644 break;
11645 }
11646 }
11647 137 }
11648
11649 46575 bool HeroClass::startwpn(int32_t itemid)
11650 {
11651
1/2
✓ Branch 0 taken 46575 times.
✗ Branch 1 not taken.
46575 if(itemid < 0) return false;
11652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46575 times.
46575 if (on_cooldown(itemid)) return false;
11653 46575 itemdata const& itm = itemsbuf[itemid];
11654
6/6
✓ Branch 0 taken 10783 times.
✓ Branch 1 taken 35792 times.
✓ Branch 2 taken 8680 times.
✓ Branch 3 taken 27112 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 116 times.
46692 if(((dir==up && y<24) || (dir==down && y>world_h-48) ||
11655
6/6
✓ Branch 0 taken 13157 times.
✓ Branch 1 taken 13955 times.
✓ Branch 2 taken 13949 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 117 times.
✓ Branch 5 taken 46452 times.
46575 (dir==left && x<32) || (dir==right && x>world_w-48)) && !(get_qr(qr_ITEMSONEDGES) || inlikelike))
11656 116 return false;
11657
11658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46459 times.
46459 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
11659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46459 times.
46459 if(liftonly)
11660 {
11661 dowpn = -1;
11662 switch(itm.type)
11663 {
11664 case itype_bomb:
11665 case itype_sbomb:
11666 if(itm.flags & item_flag4)
11667 do_liftglove(-1,false);
11668 break;
11669 case itype_liftglove:
11670 do_liftglove(-1,false);
11671 break;
11672 }
11673 return false;
11674 }
11675
11676 46459 int32_t wx=x;
11677 46459 int32_t wy=y-fakez;
11678 46459 int32_t wz=z;
11679 46459 bool ret = true;
11680
11681
5/5
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10764 times.
✓ Branch 2 taken 8648 times.
✓ Branch 3 taken 13126 times.
✓ Branch 4 taken 13915 times.
46459 switch(dir)
11682 {
11683 case up:
11684 10764 wy-=16;
11685 10764 break;
11686
11687 case down:
11688 8648 wy+=16;
11689 8648 break;
11690
11691 case left:
11692 13126 wx-=16;
11693 13126 break;
11694
11695 case right:
11696 13915 wx+=16;
11697 13915 break;
11698 }
11699
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46459 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46459 if (IsSideSwim() && (itm.flags & item_sideswim_disabled)) return false;
11700
11701
17/28
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 1174 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1379 times.
✓ Branch 6 taken 2486 times.
✓ Branch 7 taken 35 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 369 times.
✓ Branch 12 taken 365 times.
✓ Branch 13 taken 1837 times.
✓ Branch 14 taken 20038 times.
✓ Branch 15 taken 1795 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 2357 times.
✓ Branch 18 taken 20 times.
✓ Branch 19 taken 13937 times.
✓ Branch 20 taken 12 times.
✓ Branch 21 taken 8 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4 times.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
46459 switch(itm.type)
11702 {
11703 case itype_liftglove:
11704 {
11705 do_liftglove(itemid,false);
11706 dowpn = -1;
11707 ret = false;
11708 break;
11709 }
11710 case itype_potion:
11711 {
11712
2/4
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
35 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11713 {
11714 return item_error();
11715 }
11716
11717 35 paymagiccost(itemid);
11718 35 start_cooldown(itemid);
11719
11720
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
35 if(itm.misc1 || itm.misc2)
11721 {
11722 35 refill_what=REFILL_ALL;
11723 35 refill_why=itemid;
11724 35 StartRefill(REFILL_ALL);
11725 35 potion_life = game->get_life();
11726 35 potion_magic = game->get_magic();
11727
11728 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11729 //music_pause();
11730 35 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11731
2/2
✓ Branch 0 taken 6288 times.
✓ Branch 1 taken 35 times.
6323 while(refill())
11732 {
11733 6288 do_refill_waitframe();
11734 }
11735
11736 //add a quest rule or an item option that lets you specify whether or not to pause music during refilling
11737 //music_resume();
11738 35 ret = false;
11739 35 }
11740
11741 35 break;
11742 }
11743 case itype_bottle:
11744 {
11745 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11746 {
11747 return item_error();
11748 }
11749 if(itm.script!=0 && (FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
11750 return false;
11751
11752 size_t bind = game->get_bottle_slot(itm.misc1);
11753 bool paidmagic = false;
11754 if(itm.script)
11755 {
11756 paidmagic = true;
11757 paymagiccost(itemid);
11758 start_cooldown(itemid);
11759
11760 int i = itemid;
11761 FFCore.reset_script_engine_data(ScriptType::Item, i);
11762 ZScriptVersion::RunScript(ScriptType::Item, itm.script, i);
11763 bind = game->get_bottle_slot(itm.misc1);
11764 }
11765 bottletype const* bt = bind ? &(QMisc.bottle_types[bind-1]) : NULL;
11766 if(bt)
11767 {
11768 word toFill[3] = { 0 };
11769 for(size_t q = 0; q < 3; ++q)
11770 {
11771 char c = bt->counter[q];
11772 if(c > -1)
11773 {
11774 if(bt->flags & (1<<q))
11775 {
11776 toFill[q] = (bt->amount[q]==100)
11777 ? game->get_maxcounter(c)
11778 : word((game->get_maxcounter(c)/100.0)*bt->amount[q]);
11779 }
11780 else toFill[q] = bt->amount[q];
11781 if(toFill[q] + game->get_counter(c) > game->get_maxcounter(c))
11782 {
11783 toFill[q] = game->get_maxcounter(c) - game->get_counter(c);
11784 }
11785 }
11786 }
11787 word max = std::max(toFill[0], std::max(toFill[1], toFill[2]));
11788 bool run = max > 0;
11789 bool check_jinxes = true;
11790 if(get_qr(qr_NO_BOTTLE_IF_ANY_COUNTER_FULL))
11791 {
11792 for(int q = 0; q < 3; ++q)
11793 {
11794 if(bt->counter[q] > -1)
11795 {
11796 check_jinxes = false;
11797 if(!toFill[q])
11798 {
11799 run = false;
11800 break;
11801 }
11802 }
11803 }
11804 }
11805 if(check_jinxes)
11806 {
11807 if((bt->flags & BTFLAG_CURESWJINX) && swordclk)
11808 run = true;
11809 else if((bt->flags & BTFLAG_CUREITJINX) && itemclk)
11810 run = true;
11811 else if((bt->flags & BTFLAG_CURESHJINX) && shieldjinxclk)
11812 run = true;
11813 }
11814 if(run || (bt->flags&BTFLAG_ALLOWIFFULL))
11815 {
11816 if(bt->flags & BTFLAG_CURESWJINX)
11817 {
11818 swordclk = 0;
11819 verifyAWpn();
11820 }
11821 if(bt->flags & BTFLAG_CUREITJINX)
11822 itemclk = 0;
11823 if(bt->flags & BTFLAG_CURESHJINX)
11824 shieldjinxclk = 0;
11825 if(!paidmagic)
11826 {
11827 paymagiccost(itemid);
11828 start_cooldown(itemid);
11829 }
11830 stop_sfx(QMisc.miscsfx[sfxLOWHEART]); //stop heart beep!
11831 sfx(itm.usesound,pan(x));
11832 for(size_t q = 0; q < 20; ++q)
11833 do_refill_waitframe();
11834 double inc = max/60.0; //1 second
11835 double xtra[3]{ 0 };
11836 for(size_t q = 0; q < 60; ++q)
11837 {
11838 if(!(q%6) && (toFill[0]||toFill[1]||toFill[2]))
11839 sfx(QMisc.miscsfx[sfxREFILL]);
11840 for(size_t j = 0; j < 3; ++j)
11841 {
11842 xtra[j] += inc;
11843 word f = floor(xtra[j]);
11844 xtra[j] -= f;
11845 if(toFill[j] > f)
11846 {
11847 toFill[j] -= f;
11848 game->change_counter(f,bt->counter[j]);
11849 }
11850 else if(toFill[j])
11851 {
11852 game->change_counter(toFill[j],bt->counter[j]);
11853 toFill[j] = 0;
11854 }
11855 }
11856 do_refill_waitframe();
11857 }
11858 for(size_t j = 0; j < 3; ++j)
11859 {
11860 if(toFill[j])
11861 {
11862 game->change_counter(toFill[j],bt->counter[j]);
11863 toFill[j] = 0;
11864 }
11865 }
11866 for(size_t q = 0; q < 20; ++q)
11867 do_refill_waitframe();
11868 game->set_bottle_slot(itm.misc1, bt->next_type);
11869 }
11870 }
11871
11872 dowpn = -1;
11873 ret = false;
11874 break;
11875 }
11876
11877 case itype_note:
11878 {
11879 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11880 {
11881 return item_error();
11882 }
11883 if(!msg_active)
11884 {
11885 if(play_combo_string(itm.misc1, current_screen))
11886 {
11887 sfx(itm.usesound);
11888 paymagiccost(itemid);
11889 start_cooldown(itemid);
11890 }
11891 }
11892 dowpn = -1;
11893 ret = false;
11894 break;
11895 }
11896
11897 case itype_mirror:
11898 doMirror(itemid);
11899 if(Quit)
11900 return false;
11901 ret = false;
11902 break;
11903
11904 case itype_rocs:
11905 {
11906
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 17 times.
369 if(!do_jump(itemid,false)) return false;
11907 352 ret = false;
11908 }
11909 352 break;
11910
11911 case itype_letter:
11912 {
11913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
8 if(current_item(itype_letter)==i_letter &&
11914
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 (cur_screen >= 128 ? special_warp_return_scr : hero_scr)->room==rP_SHOP &&
11915
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 (cur_screen >= 128 ? special_warp_return_scr : hero_scr)->guy &&
11916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 ((cur_screen<128&&!(DMaps[cur_dmap].flags&dmfGUYCAVES))
11917
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 ||(cur_screen>=128&&DMaps[cur_dmap].flags&dmfGUYCAVES)) &&
11918 4 checkbunny(itemid)
11919 )
11920 {
11921 4 int32_t usedid = getItemID(itemsbuf, itype_letter,i_letter+1);
11922
11923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(usedid != -1)
11924 4 getitem(usedid, true, true);
11925
11926
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 sfx((cur_screen >= 128 ? special_warp_return_scr : hero_scr)->secretsfx);
11927 4 setupscreen();
11928 4 action=none; FFCore.setHeroAction(none);
11929 4 start_cooldown(itemid);
11930 4 }
11931
11932 4 ret = false;
11933 }
11934 4 break;
11935
11936 case itype_whistle:
11937 {
11938 bool whistleflag;
11939
11940
4/4
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 365 times.
365 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
11941 {
11942 12 return item_error();
11943 }
11944
11945 365 paymagiccost(itemid);
11946 365 start_cooldown(itemid);
11947 365 sfx(itm.usesound);
11948
11949
4/4
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 143 times.
✓ Branch 3 taken 143 times.
365 if(dir==up || dir==right)
11950 222 ++blowcnt;
11951 else
11952 143 --blowcnt;
11953
11954 365 uint32_t frames_to_wait = 0;
11955
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 359 times.
365 if (replay_is_active())
11956 {
11957 // How long an sfx takes to play (`sfx_allocated`) is not deterministic,
11958 // use a fixed number of frames in replay mode.
11959 // This has changed over time.
11960
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 142 times.
359 if (replay_version_check(0, 26))
11961 {
11962 217 frames_to_wait = 180;
11963 217 }
11964
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 60 times.
142 else if (replay_version_check(27, 31))
11965 {
11966 82 frames_to_wait = 0;
11967 82 }
11968 else
11969 {
11970 60 SAMPLE* sample = sfx_get_sample(itm.usesound);
11971
2/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
60 if (sample && sample->freq)
11972 60 frames_to_wait = 60 * sample->len / sample->freq;
11973 }
11974 359 }
11975
11976 365 int sfx_count = 0;
11977
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 49651 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 49657 times.
✓ Branch 6 taken 49298 times.
✓ Branch 7 taken 365 times.
49663 while ((!replay_is_active() && sfx_allocated(itm.usesound)) || (replay_is_active() && sfx_count < frames_to_wait))
11978 {
11979 49298 sfx_count += 1;
11980 49298 advanceframe(true);
11981
11982
1/2
✓ Branch 0 taken 49298 times.
✗ Branch 1 not taken.
49298 if(Quit)
11983 return false;
11984 }
11985
11986
9/14
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 359 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 359 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 359 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 359 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 359 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 365 times.
✓ Branch 13 taken 6 times.
365 Lwpns.add(new weapon(x,y-fakez,z,wWhistle,0,0,dir,itemid,getUID(),false,0,1,0));
11987
11988
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 102 times.
365 if((whistleflag=trigger_secrets_if_flag(x,y,mfWHISTLE,get_qr(qr_PERMANENT_WHISTLE_SECRETS))))
11989 102 didstuff |= did_whistle;
11990
11991
3/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 259 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
365 if((didstuff&did_whistle && itm.flags&item_flag1) || cur_screen>=128)
11992 106 return false;
11993
11994
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 239 times.
259 if(itm.flags&item_flag1) didstuff |= did_whistle;
11995
11996
4/4
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 226 times.
259 if((hero_scr->flags&fWHISTLE) || (hero_scr->flags7 & fWHISTLEWATER)
11997
1/2
✓ Branch 0 taken 220 times.
✗ Branch 1 not taken.
220 || (hero_scr->flags7&fWHISTLEPAL))
11998 {
11999 33 whistleclk=0; // signal to start drying lake or doing other stuff
12000 33 }
12001 else
12002 {
12003 226 int32_t where = itm.misc1;
12004
12005
2/2
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 14 times.
226 if(where>right) where=dir^1;
12006
12007
5/6
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 68 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 152 times.
378 if(((DMaps[cur_dmap].flags&dmfWHIRLWIND && TriforceCount()) || DMaps[cur_dmap].flags&dmfWHIRLWINDRET) &&
12008
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
158 itm.misc2 >= 0 && itm.misc2 <= 8 && !whistleflag)
12009 {
12010
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 150 times.
✓ Branch 2 taken 140 times.
✓ Branch 3 taken 10 times.
152 zfix windx = where == left ? (zfix)(viewport.right()-16) : where == right ? (zfix)viewport.left() : x;
12011
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 142 times.
✓ Branch 3 taken 6 times.
152 zfix windy = where == down ? (zfix)viewport.top() : where == up ? zfix(viewport.bottom()-16) : y;
12012
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
304 Lwpns.add(new weapon(
12013
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 windx,
12014
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 windy,
12015
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 (zfix)0,
12016 wWind,
12017 0, //type
12018 0,
12019 152 where,
12020
1/2
✓ Branch 0 taken 152 times.
✗ Branch 1 not taken.
152 itemid,getUID(),false,false,true,0)); //last arg is byte special, used to override type for wWind for now. -Z 18JULY2020
12021 152 }
12022
12023 220 whistleitem=itemid;
12024 }
12025
12026 253 ret = false;
12027 }
12028 253 break;
12029
12030 case itype_bomb: case itype_sbomb:
12031 {
12032 1379 bool sbomb = (itm.type == itype_sbomb);
12033 1379 auto lit_ty = sbomb ? wLitSBomb : wLitBomb;
12034 1379 auto boom_ty = sbomb ? wSBomb : wBomb;
12035 //Remote detonation
12036
3/4
✓ Branch 0 taken 1379 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1375 times.
1379 if(Lwpns.idCount(lit_ty) >= zc_max(itm.misc2,1))
12037 {
12038 4 weapon *ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(lit_ty)));
12039
12040
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 while(Lwpns.idCount(lit_ty) && ew->misc == 0)
12041 {
12042 //If this ever needs a version check, in the future. -z
12043 if (boom_ty == wBomb && (FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31)))
12044 {
12045 if ( ew->power > 1 ) //Don't reduce 1 to 0. -Z
12046 ew->power *= 0.5; //Remote bombs were dealing double damage. -Z
12047 }
12048 ew->misc=50;
12049 ew->clk=ew->misc-3;
12050 ew->id=boom_ty;
12051 ew = (weapon*)(Lwpns.spr(Lwpns.idFirst(lit_ty)));
12052 }
12053
12054 4 deselectbombs(sbomb);
12055 4 return false;
12056 }
12057
12058
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1375 if((itm.flags & item_flag4) && lift_wpn)
12059 {
12060 do_liftglove(-1,false); //Throw the already-held weapon
12061 start_cooldown(itemid);
12062 return false;
12063 }
12064
2/4
✓ Branch 0 taken 1375 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1375 times.
1375 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12065 {
12066 return item_error();
12067 }
12068
12069 1375 paymagiccost(itemid);
12070 1375 start_cooldown(itemid);
12071
12072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1375 times.
1375 if(itm.misc1>0) // If not remote bombs
12073 1375 deselectbombs(sbomb);
12074
12075
2/2
✓ Branch 0 taken 407 times.
✓ Branch 1 taken 968 times.
1375 if(isdungeon())
12076 {
12077
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 932 times.
968 wy=zc_max(wy,16);
12078 968 }
12079
12080
4/8
✓ Branch 0 taken 1375 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1375 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1375 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1375 times.
✗ Branch 7 not taken.
2750 weapon* wpn = new weapon((zfix)wx,(zfix)wy,(zfix)wz,lit_ty,itm.level,
12081
2/4
✓ Branch 0 taken 1375 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1375 times.
✗ Branch 3 not taken.
1375 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true);
12082 1375 bool lifted = false;
12083
2/2
✓ Branch 0 taken 1358 times.
✓ Branch 1 taken 17 times.
1375 if(itm.flags & item_flag4)
12084 {
12085 17 auto liftid = current_item_id(itype_liftglove);
12086
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
17 if(liftid > -1 && (itm.weap_data.lift_level <= itemsbuf[liftid].level))
12087 {
12088 17 lift(wpn, itm.weap_data.lift_time, itm.weap_data.lift_height);
12089 17 set_liftflags(liftid);
12090 17 lifted = true;
12091 17 }
12092 17 }
12093
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1358 times.
1375 if(!lifted)
12094 {
12095 1358 Lwpns.add(wpn);
12096 1358 sfx(WAV_PLACE,pan(wx));
12097 1358 }
12098 }
12099 1375 break;
12100
12101 case itype_wand:
12102 {
12103
2/2
✓ Branch 0 taken 440 times.
✓ Branch 1 taken 1397 times.
1837 if(Lwpns.idCount(wMagic))
12104 {
12105 440 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12106 440 return false;
12107 }
12108
12109 1397 int32_t bookid = current_item_id(itype_book);
12110
3/4
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 681 times.
✓ Branch 2 taken 716 times.
✗ Branch 3 not taken.
1397 if (bookid > -1 && on_cooldown(bookid))
12111 bookid = -1;
12112
3/4
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 681 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 716 times.
1397 bool paybook = (bookid>-1 && checkbunny(bookid) && checkmagiccost(bookid));
12113
12114
4/4
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 1224 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 139 times.
1397 if(!(itm.flags&item_flag1) && !paybook) //Can the wand shoot without the book?
12115 {
12116 139 misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12117 139 return false;
12118 }
12119
12120
4/6
✓ Branch 0 taken 1258 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1258 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1255 times.
✓ Branch 5 taken 3 times.
1258 if(!checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_WAND_COST || checkmagiccost(itemid)))
12121 {
12122 3 return item_error();
12123 }
12124
12125
2/2
✓ Branch 0 taken 1251 times.
✓ Branch 1 taken 4 times.
1255 if(Lwpns.idCount(wBeam))
12126 4 Lwpns.del(Lwpns.idFirst(wBeam));
12127
12128 int32_t type, pow;
12129
2/2
✓ Branch 0 taken 533 times.
✓ Branch 1 taken 722 times.
1255 if ( get_qr(qr_BROKENBOOKCOST) )
12130 {
12131
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 120 times.
533 type = bookid != -1 ? current_item(itype_book) : itm.level;
12132
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 120 times.
533 pow = (bookid != -1 ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
12133 533 }
12134 else
12135 {
12136
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 419 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
722 type = (bookid != -1 && paybook) ? current_item(itype_book) : itm.level;
12137
3/4
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 419 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 303 times.
722 pow = ((bookid != -1 && paybook) ? current_item_power(itype_book) : itm.power)*game->get_hero_dmgmult();
12138 }
12139
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2510 times.
✓ Branch 4 taken 1255 times.
✓ Branch 5 taken 1255 times.
2510 for(int32_t i=(spins==1?up:dir); i<=(spins==1 ? right:dir); i++)
12140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
2510 if(dir!=(i^1))
12141 {
12142
5/10
✓ Branch 0 taken 1255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1255 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1255 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1255 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1255 times.
✗ Branch 9 not taken.
1255 weapon *magic = new weapon((zfix)wx,(zfix)wy,(zfix)wz,wMagic,type,pow,i, itemid,getUID(),false,false,true);
12143
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 716 times.
1255 if(paybook)
12144 716 magic->linkedItem = bookid;
12145 //magic->dir = this->dir; //Save player dir for special weapons.
12146 1255 Lwpns.add(magic);
12147 1255 }
12148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1255 times.
1255 if(!(misc_internal_hero_flags & LF_PAID_WAND_COST))
12149 1255 paymagiccost(itemid);
12150 else misc_internal_hero_flags &= ~LF_PAID_WAND_COST;
12151
12152
2/2
✓ Branch 0 taken 539 times.
✓ Branch 1 taken 716 times.
1255 if(paybook)
12153 {
12154 716 paymagiccost(bookid);
12155 716 start_cooldown(bookid);
12156 716 }
12157
12158 1255 start_cooldown(itemid);
12159
12160
2/2
✓ Branch 0 taken 716 times.
✓ Branch 1 taken 539 times.
1255 if(bookid != -1)
12161 {
12162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 716 times.
716 if (( itemsbuf[bookid].flags & item_flag4 ))
12163 {
12164 sfx(itemsbuf[bookid].misc2,pan(wx));
12165 }
12166 else
12167 {
12168 716 sfx(itm.usesound,pan(wx));
12169 }
12170 716 }
12171 else
12172 539 sfx(itm.usesound,pan(wx));
12173 }
12174 /*
12175 // Fireball Wand
12176 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wRefFireball,0,2*game->get_hero_dmgmult(),dir));
12177 switch (dir)
12178 {
12179 case up:
12180 Lwpns.spr(Lwpns.Count()-1)->angle=-PI/2;
12181 Lwpns.spr(Lwpns.Count()-1)->dir=up;
12182 break;
12183 case down:
12184 Lwpns.spr(Lwpns.Count()-1)->angle=PI/2;
12185 Lwpns.spr(Lwpns.Count()-1)->dir=down;
12186 break;
12187 case left:
12188 Lwpns.spr(Lwpns.Count()-1)->angle=PI;
12189 Lwpns.spr(Lwpns.Count()-1)->dir=left;
12190 break;
12191 case right:
12192 Lwpns.spr(Lwpns.Count()-1)->angle=0;
12193 Lwpns.spr(Lwpns.Count()-1)->dir=right;
12194 break;
12195 }
12196 Lwpns.spr(Lwpns.Count()-1)->clk=16;
12197 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step=3.5;
12198 Lwpns.spr(Lwpns.Count()-1)->dummy_bool[0]=true; //homing
12199 */
12200 1255 break;
12201
12202 case itype_sword:
12203 {
12204
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20038 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
20038 if(!(checkbunny(itemid) || !(misc_internal_hero_flags & LF_PAID_SWORD_COST || checkmagiccost(itemid))))
12205 {
12206 return item_error();
12207 }
12208
12209
4/4
✓ Branch 0 taken 4269 times.
✓ Branch 1 taken 15769 times.
✓ Branch 2 taken 4269 times.
✓ Branch 3 taken 15769 times.
20038 if((Lwpns.idCount(wBeam) && spins==0)||Lwpns.idCount(wMagic))
12210 {
12211 4269 misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12212 4269 return false;
12213 }
12214
12215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15769 times.
15769 if(!(misc_internal_hero_flags & LF_PAID_SWORD_COST))//If already paid to use sword melee, don't charge again
12216 15769 paymagiccost(itemid);
12217 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
12218
12219 15769 start_cooldown(itemid);
12220
12221 int temppower;
12222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15769 times.
15769 if(itm.flags & item_flag2)
12223 {
12224 15769 temppower=game->get_hero_dmgmult()*itm.power;
12225 15769 temppower=temppower*itm.misc2;
12226 15769 temppower=temppower/100;
12227 15769 }
12228 else
12229 {
12230 temppower = game->get_hero_dmgmult()*itm.misc2;
12231 }
12232
12233
5/10
✓ Branch 0 taken 15769 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15769 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15769 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15769 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15769 times.
✗ Branch 9 not taken.
15769 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBeam,itm.level,temppower,dir,itemid,getUID(),false,false,true));
12234 15769 sfx(itm.usesound2, pan(wx));
12235 }
12236 15769 break;
12237
12238 case itype_candle:
12239 {
12240 1795 int32_t countid = itemid;
12241
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 1716 times.
1795 if(get_qr(qr_CANDLES_SHARED_LIMIT))
12242 1716 countid = -itype_candle;
12243
5/6
✓ Branch 0 taken 1399 times.
✓ Branch 1 taken 396 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 396 times.
✓ Branch 4 taken 19 times.
✓ Branch 5 taken 1776 times.
1795 if(itm.flags&item_flag1 && usecounts[countid] >= zc_max(1, itm.misc3))
12244 {
12245 19 return false;
12246 }
12247
12248
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1776 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 1680 times.
1776 if(Lwpns.idCount(wFire) >= (itm.misc2 < 1 ? 2 : itm.misc2))
12249 {
12250 96 return false;
12251 }
12252
12253
3/4
✓ Branch 0 taken 1680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 1671 times.
1680 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12254 {
12255 9 return item_error();
12256 }
12257
12258 1671 paymagiccost(itemid);
12259 1671 start_cooldown(itemid);
12260
12261
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 1302 times.
1671 if(itm.flags&item_flag1) ++usecounts[countid];
12262
12263
4/8
✓ Branch 0 taken 1671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1671 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1671 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1671 times.
✗ Branch 7 not taken.
3342 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wFire,
12264 //(itm.fam_type > 1), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
12265 1671 (itm.level), //To do with combo flags ... Needs to be changed to fix ->Level for wFire
12266
2/4
✓ Branch 0 taken 1671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1671 times.
✗ Branch 3 not taken.
1671 itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12267 1671 sfx(itm.usesound,pan(wx));
12268 1671 attack=wFire;
12269 }
12270 1671 break;
12271
12272 case itype_script1: case itype_script2: case itype_script3: case itype_script4: case itype_script5:
12273 case itype_script6: case itype_script7: case itype_script8: case itype_script9: case itype_script10:
12274 {
12275 int32_t wtype = wScript1 + (itm.type-itype_script1);
12276 if(Lwpns.idCount(wtype))
12277 return false;
12278
12279 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12280 {
12281 return item_error();
12282 }
12283
12284 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
12285 paymagiccost(itemid);
12286 start_cooldown(itemid);
12287
12288 zfix wpnstep = zfix(itm.misc1)/100;
12289 if(replay_version_check(0,30))
12290 wpnstep = itm.misc1/100;
12291
12292 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wtype,itm.level,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12293 if(!(itm.weap_data.flags & wdata_set_step))
12294 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = wpnstep;
12295 sfx(itm.usesound,pan(wx));
12296 }
12297 break;
12298
12299 case itype_icerod:
12300 {
12301 if(Lwpns.idCount(wIce))
12302 return false;
12303
12304 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12305 {
12306 return item_error();
12307 }
12308
12309 if(!get_qr(qr_CUSTOMWEAPON_IGNORE_COST))
12310 paymagiccost(itemid);
12311 start_cooldown(itemid);
12312
12313 zfix wpnstep = zfix(itm.misc1)/100;
12314 if(replay_version_check(0,30))
12315 wpnstep = itm.misc1/100;
12316
12317 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wIce,itm.level,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12318 if(!(itm.weap_data.flags & wdata_set_step))
12319 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step = wpnstep;
12320 sfx(itm.usesound,pan(wx));
12321 }
12322 break;
12323
12324 case itype_arrow:
12325 {
12326
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2357 times.
✓ Branch 2 taken 89 times.
✓ Branch 3 taken 2268 times.
2357 if(Lwpns.idCount(wArrow) >= (itm.misc2 < 1 ? 1 : itm.misc2))
12327 89 return false;
12328
12329
3/4
✓ Branch 0 taken 2268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 2254 times.
2268 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12330 {
12331 14 return item_error();
12332 }
12333
12334 2254 paymagiccost(itemid);
12335 2254 start_cooldown(itemid);
12336
12337
6/12
✓ Branch 0 taken 2254 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2254 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2254 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2254 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2254 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2254 times.
✗ Branch 11 not taken.
2254 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wArrow,itm.level,game->get_hero_dmgmult()*itm.power,dir,itemid,getUID(),false,false,true));
12338 2254 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->step*=(current_item_power(itype_bow)+1)/2;
12339 2254 sfx(itm.usesound,pan(wx));
12340 }
12341 2254 break;
12342
12343 case itype_bait:
12344 {
12345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(Lwpns.idCount(wBait)) //TODO: More than one Bait per screen?
12346 return false;
12347
12348
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3 times.
20 if(!checkbunny(itemid))
12349 3 return item_error();
12350
12351
4/6
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
33 bool grumble = (hero_scr->room==rGRUMBLE && (!getmapflag(hero_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (hero_scr->flags9&fBELOWRETURN)));
12352
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 bool checkcost = grumble || !(itm.flags & item_flag4);
12353
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 bool paycost = grumble || !(itm.flags & (item_flag4|item_flag5));
12354
12355
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
17 if(!grumble && (itm.flags & item_flag2))
12356 return item_error(); //Only usable for grumble rooms
12357
12358
2/4
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17 times.
✗ Branch 3 not taken.
17 if(checkcost && !checkmagiccost(itemid))
12359 return item_error();
12360
12361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(paycost)
12362 17 paymagiccost(itemid);
12363 17 start_cooldown(itemid);
12364 17 sfx(itm.usesound,pan(wx));
12365
12366
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1 times.
17 if(grumble)
12367 {
12368
4/8
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
16 items.add(new item((zfix)wx,(zfix)wy,(zfix)0,itemid,ipDUMMY+ipFADE,0));
12369 16 fadeclk=66;
12370 16 dismissmsg();
12371 16 clear_bitmap(pricesdisplaybuf);
12372 16 set_clip_state(pricesdisplaybuf, 1);
12373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 setmapflag(hero_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
12374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!(itm.flags & item_flag3)) //"Don't remove when feeding" flag
12375 {
12376 16 removeItemsOfFamily(game,itemsbuf,itype_bait);
12377 16 verifyBothWeapons();
12378 16 }
12379 16 sfx(hero_scr->secretsfx);
12380 16 return false;
12381 }
12382
12383
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBait,0,0,dir,itemid,getUID(),false,false,true));
12384 1 break;
12385 }
12386
12387 case itype_brang:
12388 {
12389
2/2
✓ Branch 0 taken 327 times.
✓ Branch 1 taken 13610 times.
13937 if(Lwpns.idCount(wBrang) > itm.misc2)
12390 327 return false;
12391
12392
2/4
✓ Branch 0 taken 13610 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13610 times.
13610 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12393 {
12394 return item_error();
12395 }
12396
12397 13610 paymagiccost(itemid);
12398 13610 start_cooldown(itemid);
12399
12400 13610 current_item_power(itype_brang);
12401
6/12
✓ Branch 0 taken 13610 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13610 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13610 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13610 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13610 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13610 times.
✗ Branch 11 not taken.
13610 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wBrang,itm.level,(itm.power*game->get_hero_dmgmult()),dir,itemid,getUID(),false,false,true));
12402 }
12403 13610 break;
12404
12405 case itype_hookshot:
12406 case itype_switchhook:
12407 {
12408
3/4
✓ Branch 0 taken 2485 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2485 times.
2486 if(inlikelike || Lwpns.idCount(wHookshot))
12409 1 return false;
12410
12411
2/4
✓ Branch 0 taken 2485 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2485 times.
2485 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12412 {
12413 return item_error();
12414 }
12415 2485 bool sw = itm.type == itype_switchhook;
12416
12417
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2483 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2485 if(sw && (itm.flags&item_flag8))
12418 switchhook_cost_item = itemid;
12419 2485 else paymagiccost(itemid);
12420
12421 2485 start_cooldown(itemid);
12422
12423 2485 bool use_hookshot=true;
12424 2485 bool hit_hs = false, hit_solid = false, insta_switch = false;
12425
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 2384 times.
2485 int32_t max_layer = get_qr(qr_HOOKSHOTALLLAYER) ? 6 : (get_qr(qr_HOOKSHOTLAYERFIX) ? 2 : 0);
12426 2485 rpos_t rpos = rpos_t::None;
12427 2485 ffcdata* ffc = nullptr;
12428
4/4
✓ Branch 0 taken 2451 times.
✓ Branch 1 taken 5772 times.
✓ Branch 2 taken 5738 times.
✓ Branch 3 taken 2485 times.
8223 for(int32_t i=0; i<=max_layer && !hit_hs; ++i)
12429 {
12430
2/2
✓ Branch 0 taken 4719 times.
✓ Branch 1 taken 1019 times.
5738 if(dir==up)
12431 {
12432
2/2
✓ Branch 0 taken 995 times.
✓ Branch 1 taken 24 times.
1019 if(check_hshot(i,x+2,y-7,sw, &rpos, &ffc))
12433 24 hit_hs = true;
12434 1019 }
12435
2/2
✓ Branch 0 taken 1046 times.
✓ Branch 1 taken 3673 times.
4719 else if(dir==down)
12436 {
12437
1/2
✓ Branch 0 taken 1046 times.
✗ Branch 1 not taken.
1046 if(check_hshot(i,x+12,y+23,sw, &rpos, &ffc))
12438 hit_hs = true;
12439 1046 }
12440
2/2
✓ Branch 0 taken 1822 times.
✓ Branch 1 taken 1851 times.
3673 else if(dir==left)
12441 {
12442
2/2
✓ Branch 0 taken 1813 times.
✓ Branch 1 taken 9 times.
1822 if(check_hshot(i,x-7,y+12,sw, &rpos, &ffc))
12443 9 hit_hs = true;
12444 1822 }
12445
1/2
✓ Branch 0 taken 1851 times.
✗ Branch 1 not taken.
1851 else if(dir==right)
12446 {
12447
2/2
✓ Branch 0 taken 1848 times.
✓ Branch 1 taken 3 times.
1851 if(check_hshot(i,x+23,y+12,sw, &rpos, &ffc))
12448 3 hit_hs = true;
12449 1851 }
12450 //Diagonal Hookshot (6)
12451 else if(dir==r_down)
12452 {
12453 if(check_hshot(i,x+9,y+13,sw, &rpos, &ffc))
12454 hit_hs = true;
12455 }
12456 else if(dir==l_down)
12457 {
12458 if(check_hshot(i,x+6,y+13,sw, &rpos, &ffc))
12459 hit_hs = true;
12460 }
12461 else if(dir==r_up)
12462 {
12463 if(check_hshot(i,x+9,y+13,sw, &rpos, &ffc))
12464 hit_hs = true;
12465 }
12466 else if(dir==l_up)
12467 {
12468 if(check_hshot(i,x+6,y+13,sw, &rpos, &ffc))
12469 hit_hs = true;
12470 }
12471 5738 }
12472
8/10
✓ Branch 0 taken 2067 times.
✓ Branch 1 taken 418 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 418 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 418 times.
✓ Branch 6 taken 364 times.
✓ Branch 7 taken 54 times.
✓ Branch 8 taken 2456 times.
✓ Branch 9 taken 29 times.
2485 if(dir==up && _walkflag(x+2,y+4,1,STANDING_Z_STATE) && !ishookshottable(x.getInt(),int32_t(y+4)))
12473 29 hit_solid = true;
12474
2/2
✓ Branch 0 taken 2449 times.
✓ Branch 1 taken 36 times.
2485 if(hit_hs)
12475 {
12476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(sw)
12477 insta_switch = true; //switch immediately
12478 36 else use_hookshot = false; //No hooking against grabbable
12479 36 }
12480
3/4
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 2456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
2485 if(hit_solid && !insta_switch)
12481 29 use_hookshot = false;
12482
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 2435 times.
2485 if(use_hookshot)
12483 {
12484 2435 int32_t hookitem = itm.level;
12485 2435 int32_t hookpower = itm.power;
12486 2435 byte allow_diagonal = (itm.flags & item_flag2) ? 1 : 0;
12487
12488
1/2
✓ Branch 0 taken 2435 times.
✗ Branch 1 not taken.
2435 if(!Lwpns.has_space())
12489 {
12490 Lwpns.del(0);
12491 }
12492
12493
1/2
✓ Branch 0 taken 2435 times.
✗ Branch 1 not taken.
2435 if(!Lwpns.has_space(2))
12494 {
12495 Lwpns.del(0);
12496 }
12497
12498
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 380 times.
✓ Branch 2 taken 440 times.
✓ Branch 3 taken 783 times.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
2435 switch(dir)
12499 {
12500 case up:
12501 {
12502 380 hookshot_used=true;
12503 380 hs_switcher = sw;
12504
4/8
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 380 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 380 times.
✗ Branch 7 not taken.
760 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12505
2/4
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
380 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12506 380 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12507
5/10
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 380 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 380 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 380 times.
✗ Branch 9 not taken.
760 Lwpns.add(new weapon((zfix)wx,(zfix)wy-4,(zfix)wz,wHookshot,hookitem,
12508
2/4
✓ Branch 0 taken 380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 380 times.
✗ Branch 3 not taken.
380 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12509 380 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12510 380 hs_startx=wx;
12511 380 hs_starty=wy-4;
12512 }
12513 380 break;
12514
12515 case down:
12516 {
12517 440 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12518 440 hookshot_used=true;
12519 440 hs_switcher = sw;
12520
5/10
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 440 times.
✗ Branch 9 not taken.
880 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12521
2/4
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
440 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12522 440 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12523
5/10
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 440 times.
✗ Branch 9 not taken.
880 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12524
2/4
✓ Branch 0 taken 440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 440 times.
✗ Branch 3 not taken.
440 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12525 440 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12526 440 hs_startx=wx;
12527 440 hs_starty=wy;
12528 }
12529 440 break;
12530
12531 case left:
12532 {
12533 783 hookshot_used=true;
12534 783 hs_switcher = sw;
12535
4/8
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 783 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 783 times.
✗ Branch 7 not taken.
1566 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12536
2/4
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
783 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12537 783 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12538
4/8
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 783 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 783 times.
✗ Branch 7 not taken.
1566 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12539
2/4
✓ Branch 0 taken 783 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 783 times.
✗ Branch 3 not taken.
783 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12540 783 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12541 783 hs_startx=wx-4;
12542 783 hs_starty=wy;
12543 }
12544 783 break;
12545
12546 case right:
12547 {
12548 832 hookshot_used=true;
12549 832 hs_switcher = sw;
12550 // TODO(crash): check that .add succeeds.
12551
4/8
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
1664 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12552
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12553 832 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12554
4/8
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 832 times.
✗ Branch 7 not taken.
1664 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12555
2/4
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 832 times.
✗ Branch 3 not taken.
832 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12556 832 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12557 832 hs_startx=wx+4;
12558 832 hs_starty=wy;
12559 }
12560 832 break;
12561 //Diagonal Hookshot (7)
12562 case r_down:
12563 {
12564 hookshot_used=true;
12565 hs_switcher = sw;
12566 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12567 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12568 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12569 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12570 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12571 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12572 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12573 hs_startx=wx+4;
12574 hs_starty=wy;
12575 }
12576 break;
12577
12578 case r_up:
12579 {
12580 hookshot_used=true;
12581 hs_switcher = sw;
12582 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12583 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12584 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12585 Lwpns.add(new weapon((zfix)(wx+4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12586 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12587 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12588 hs_startx=wx+4;
12589 hs_starty=wy;
12590 }
12591 break;
12592
12593 case l_down:
12594 {
12595 hookshot_used=true;
12596 hs_switcher = sw;
12597 int32_t offset=get_qr(qr_HOOKSHOTDOWNBUG)?4:0;
12598 Lwpns.add(new weapon((zfix)wx,(zfix)wy+offset,(zfix)wz,wHSHandle,hookitem,
12599 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12600 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12601 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy+offset,(zfix)wz,wHookshot,hookitem,
12602 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12603 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12604 hs_startx=wx+4;
12605 hs_starty=wy;
12606 }
12607 break;
12608
12609 case l_up:
12610 {
12611 hookshot_used=true;
12612 hs_switcher = sw;
12613 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wHSHandle,hookitem,
12614 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12615 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12616 Lwpns.add(new weapon((zfix)(wx-4),(zfix)wy,(zfix)wz,wHookshot,hookitem,
12617 hookpower*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12618 ((weapon*)Lwpns.spr(Lwpns.Count()-1))->family_class = itm.type;
12619 hs_startx=wx+4;
12620 hs_starty=wy;
12621 }
12622 break;
12623 }
12624 2435 hookshot_frozen=true;
12625 2435 }
12626
1/2
✓ Branch 0 taken 2485 times.
✗ Branch 1 not taken.
2485 if(insta_switch)
12627 {
12628 weapon* w = (weapon*)Lwpns.spr(Lwpns.idFirst(wHookshot));
12629 if (rpos != rpos_t::None) hooked_comborpos = rpos;
12630 if (ffc)
12631 {
12632 ffc->switch_hooked = true;
12633 switching_object = ffc;
12634 }
12635 w->misc=2;
12636 w->step=0;
12637 doSwitchHook(itm.misc5);
12638 if(itm.usesound2)
12639 sfx(itm.usesound2,pan(x));
12640 else if(QMisc.miscsfx[sfxSWITCHED])
12641 sfx(QMisc.miscsfx[sfxSWITCHED],pan(x));
12642 stop_sfx(itm.usesound);
12643 }
12644 }
12645 2485 break;
12646
12647 case itype_divinefire:
12648
3/12
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
12 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12649 return false;
12650
12651
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12652 {
12653 return item_error();
12654 }
12655
12656 12 paymagiccost(itemid);
12657 12 start_cooldown(itemid);
12658
12659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12660 12 else {action=casting; FFCore.setHeroAction(casting);}
12661 12 magicitem=itemid;
12662 12 break;
12663
12664 case itype_divineescape:
12665
3/12
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
8 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12666 return false;
12667
12668
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12669 {
12670 return item_error();
12671 }
12672
12673 8 paymagiccost(itemid);
12674 8 start_cooldown(itemid);
12675
12676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12677 8 else {action=casting; FFCore.setHeroAction(casting);}
12678 8 magicitem=itemid;
12679 8 break;
12680
12681 case itype_divineprotection:
12682 if(z!=0 || fakez!=0 || (isSideViewHero() && !(on_sideview_solid_oldpos(this) || getOnSideviewLadder() || IsSideSwim())))
12683 return false;
12684
12685 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12686 {
12687 return item_error();
12688 }
12689
12690 paymagiccost(itemid);
12691 start_cooldown(itemid);
12692
12693 if (IsSideSwim()) {action=sideswimcasting; FFCore.setHeroAction(sideswimcasting);}
12694 else {action=casting; FFCore.setHeroAction(casting);}
12695 magicitem=itemid;
12696 break;
12697
12698 case itype_cbyrna:
12699 {
12700 //Beams already deployed
12701
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if(Lwpns.idCount(wCByrna))
12702 {
12703 2 stopCaneOfByrna();
12704 2 return false;
12705 }
12706
12707
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12708 {
12709 stop_sfx(itm.usesound); //if we can't pay the cost, kill the sound.
12710 //last_cane_of_byrna_item_id = -1; //no, we'd do this in a byrna cleanup function.
12711 return false;
12712 }
12713
12714 2 paymagiccost(itemid);
12715 2 start_cooldown(itemid);
12716
12717 2 last_cane_of_byrna_item_id = itemid;
12718
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 for(int32_t i=0; i<itm.misc3; i++)
12719 {
12720 //byrna weapons are added here
12721 //space them apart
12722 //the iterator isn passed to 'type'. weapons.cpp converts thisd to
12723 //'quantity_iterator' pn construction; and this is used for orbit initial spacing.
12724
6/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
2 Lwpns.add(new weapon((zfix)wx,(zfix)wy,(zfix)wz,wCByrna,i,itm.power*game->get_hero_dmgmult(),dir,itemid,getUID(),false,false,true));
12725 2 }
12726
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(Lwpns.idCount(wCByrna)))
12727 stop_sfx(itm.usesound); //If we can't create the beams, kill the sound.
12728 }
12729 2 break;
12730
12731 case itype_clock:
12732 {
12733 ret = false;
12734 if(!(itm.flags & item_flag1))
12735 break; //Passive clock, don't use
12736 if((itm.flags & item_flag2) && watch) //"Can't activate while clock active"
12737 break;
12738 if(!(checkbunny(itemid) && checkmagiccost(itemid))) //cost/bunny check
12739 {
12740 return item_error();
12741 }
12742
12743 paymagiccost(itemid);
12744 start_cooldown(itemid);
12745
12746 setClock(watch=true);
12747
12748 clock_zoras.clear();
12749
12750 clockclk=itm.misc1;
12751 sfx(itm.usesound);
12752 break;
12753 }
12754 case itype_killem:
12755 {
12756 ret = false;
12757 if(!(itm.flags & item_flag1))
12758 break; //Passive killemall, don't use
12759
12760 if(!(checkbunny(itemid) && checkmagiccost(itemid))
12761 || !can_kill_em_all()) //No enemies onscreen
12762 {
12763 return item_error();
12764 }
12765
12766 paymagiccost(itemid);
12767 start_cooldown(itemid);
12768
12769 kill_em_all();
12770 sfx(itm.usesound);
12771 break;
12772 }
12773 case itype_refill:
12774 {
12775 if(!(checkbunny(itemid) && checkmagiccost(itemid)))
12776 {
12777 return item_error();
12778 }
12779
12780 bool did_something = false;
12781
12782 if(itm.flags & item_flag1) //Cure sword jinx
12783 {
12784 if(swordclk)
12785 did_something = true;
12786 swordclk = 0;
12787 verifyAWpn();
12788 }
12789 for(auto q = 0; q < 5; ++q)
12790 {
12791 auto ctr = itm.misc(q);
12792 if(unsigned(ctr) >= MAX_COUNTERS)
12793 continue;
12794 int16_t amnt = vbound(itm.misc(q+5),-32768,32767);
12795 if(!amnt) continue;
12796 bool gradual = itm.flags & item_flag2;
12797 if(amnt > 0)
12798 {
12799 if(game->get_counter(ctr) + game->get_dcounter(ctr) >= game->get_maxcounter(ctr))
12800 {
12801 //Can't *do* anything... skip
12802 continue;
12803 }
12804 if(game->get_counter(ctr) >= game->get_maxcounter(ctr))
12805 {
12806 //Can't do anything unless affecting dcounter
12807 gradual = true;
12808 }
12809 }
12810 else //Negative
12811 {
12812 if(game->get_counter(ctr) + game->get_dcounter(ctr) <= 0)
12813 {
12814 //Can't *do* anything... skip
12815 continue;
12816 }
12817 if(game->get_counter(ctr) <= 0)
12818 {
12819 //Can't do anything unless affecting dcounter
12820 gradual = true;
12821 }
12822 }
12823 did_something = true;
12824 if(gradual) //Gradual
12825 {
12826 game->change_dcounter(amnt, ctr);
12827 }
12828 else
12829 {
12830 game->change_counter(amnt, ctr);
12831 }
12832 }
12833 if(!did_something)
12834 {
12835 return item_error();
12836 }
12837 paymagiccost(itemid);
12838 start_cooldown(itemid);
12839 sfx(itm.usesound);
12840 ret = false;
12841 break;
12842 }
12843
12844 case itype_lens:
12845 // don't start cooldown here, it's activated elsewhere
12846 639 ret = false;
12847 639 break;
12848 case itype_shield:
12849 if (!(itm.flags & item_flag9)) // don't start cooldown here for active shields
12850 start_cooldown(itemid);
12851 ret = false;
12852 break;
12853 default:
12854 1174 start_cooldown(itemid);
12855 1174 ret = false;
12856 1174 break;
12857 }
12858
12859
2/2
✓ Branch 0 taken 40864 times.
✓ Branch 1 taken 35 times.
40899 if(itm.flags & item_downgrade)
12860 {
12861 35 game->set_item(itemid,false);
12862
12863 // Maybe Item Override has allowed the same item in both slots?
12864
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Bwpn == itemid)
12865 {
12866 Bwpn = -1;
12867 game->forced_bwpn = -1;
12868 verifyBWpn();
12869 }
12870
12871
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Awpn == itemid)
12872 {
12873 Awpn = -1;
12874 game->forced_awpn = -1;
12875 verifyAWpn();
12876 }
12877
12878
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Xwpn == itemid)
12879 {
12880 Xwpn = -1;
12881 game->forced_xwpn = -1;
12882 verifyXWpn();
12883 }
12884
12885
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 if(Ywpn == itemid)
12886 {
12887 Ywpn = -1;
12888 game->forced_ywpn = -1;
12889 verifyYWpn();
12890 }
12891 35 }
12892
12893 40899 return ret;
12894 46581 }
12895 65656644 bool HeroClass::on_cooldown(int32_t itemid)
12896 {
12897
3/4
✓ Branch 0 taken 37430151 times.
✓ Branch 1 taken 28226493 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37430151 times.
65656644 if (itemid < 0 || itemid >= MAXITEMS) return false;
12898 37430151 return item_cooldown[itemid];
12899 65656644 }
12900 41411 void HeroClass::start_cooldown(int32_t itemid)
12901 {
12902
2/4
✓ Branch 0 taken 41411 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41411 times.
41411 if (itemid < 0 || itemid >= MAXITEMS) return;
12903
1/2
✓ Branch 0 taken 41411 times.
✗ Branch 1 not taken.
41411 if (item_cooldown[itemid] < 0) return; // set to perma-cooldown (via script, presumably)
12904 41411 auto cd_data = calc_item_cooldown(itemid);
12905
1/2
✓ Branch 0 taken 41411 times.
✗ Branch 1 not taken.
41411 if(cd_data.max_cooldown <= 0) return;
12906 if(cd_data.max_cooldown > item_cooldown[itemid])
12907 {
12908 item_cooldown[itemid] = cd_data.max_cooldown;
12909 paymagiccost(cd_data.cooldown_ring_id);
12910 }
12911 else if(cd_data.base_cooldown > item_cooldown[itemid]) // cd ring still *did something*, so still pay
12912 paymagiccost(cd_data.cooldown_ring_id);
12913 41411 }
12914
12915 1866001 bool HeroClass::doattack()
12916 {
12917
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1865984 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1866001 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
12918 17 return false;
12919 //int32_t s = BSZ ? 0 : 11;
12920 1865984 int32_t s = (zinit.heroAnimationStyle==las_bszelda) ? 0 : 11;
12921
12922
4/4
✓ Branch 0 taken 475791 times.
✓ Branch 1 taken 1390193 times.
✓ Branch 2 taken 475647 times.
✓ Branch 3 taken 144 times.
1865984 int32_t bugnetid = (directWpn>-1 && itemsbuf[directWpn].type==itype_bugnet) ? directWpn : current_item_id(itype_bugnet);
12923
3/4
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 1865840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
1865984 if(attack==wBugNet && bugnetid!=-1)
12924 {
12925
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 138 times.
144 if(++attackclk >= NET_CLK_TOTAL)
12926 6 return false;
12927
12928 138 return true;
12929 }
12930
12931 // Abort attack if attackclk has run out and:
12932 // * the attack is not Hammer, Sword with Spin Scroll, Candle, or Wand, OR
12933 // * you aren't holding down the A button, you're not charging, and/or you're still spinning
12934
12935
6/6
✓ Branch 0 taken 183383 times.
✓ Branch 1 taken 1682457 times.
✓ Branch 2 taken 147865 times.
✓ Branch 3 taken 35518 times.
✓ Branch 4 taken 51479 times.
✓ Branch 5 taken 17820 times.
1935139 if(attackclk>=(spins>0?8:14) && attack!=wHammer &&
12936
12/12
✓ Branch 0 taken 135414 times.
✓ Branch 1 taken 12451 times.
✓ Branch 2 taken 66239 times.
✓ Branch 3 taken 69175 times.
✓ Branch 4 taken 79830 times.
✓ Branch 5 taken 68035 times.
✓ Branch 6 taken 78566 times.
✓ Branch 7 taken 1264 times.
✓ Branch 8 taken 66199 times.
✓ Branch 9 taken 3100 times.
✓ Branch 10 taken 50945 times.
✓ Branch 11 taken 15254 times.
147865 (((attack!=wSword || !current_item(itype_spinscroll) || inlikelike) && attack!=wWand && attack!=wFire && attack!=wCByrna) || !((attack==wSword && isWpnPressed(itype_sword) && spins==0) || charging>0)))
12937 {
12938 96386 tapping=false;
12939 96386 return false;
12940 }
12941
12942
2/2
✓ Branch 0 taken 2297 times.
✓ Branch 1 taken 1767157 times.
1769454 if(attackclk>29)
12943 {
12944 2297 tapping=false;
12945 2297 return false;
12946 }
12947
12948
4/4
✓ Branch 0 taken 457820 times.
✓ Branch 1 taken 1309337 times.
✓ Branch 2 taken 434838 times.
✓ Branch 3 taken 22982 times.
1767157 int32_t candleid = (directWpn>-1 && itemsbuf[directWpn].type==itype_candle) ? directWpn : current_item_id(itype_candle);
12949
4/4
✓ Branch 0 taken 457820 times.
✓ Branch 1 taken 1309337 times.
✓ Branch 2 taken 457790 times.
✓ Branch 3 taken 30 times.
1767157 int32_t byrnaid = (directWpn>-1 && itemsbuf[directWpn].type==itype_cbyrna) ? directWpn : current_item_id(itype_cbyrna);
12950 // An attack can be "walked out-of" after 8 frames, unless it's:
12951 // * a sword stab
12952 // * a hammer pound
12953 // * a wand thrust
12954 // * a candle thrust
12955 // * a cane thrust
12956 // In which case it should continue.
12957
8/8
✓ Branch 0 taken 68903 times.
✓ Branch 1 taken 1698254 times.
✓ Branch 2 taken 197612 times.
✓ Branch 3 taken 128709 times.
✓ Branch 4 taken 1623406 times.
✓ Branch 5 taken 203557 times.
✓ Branch 6 taken 361124 times.
✓ Branch 7 taken 1262282 times.
2063171 if((attack==wCatching && attackclk>4)||(attack!=wWand && attack!=wSword && attack!=wHammer
12958
5/6
✓ Branch 0 taken 296702 times.
✓ Branch 1 taken 64422 times.
✓ Branch 2 taken 22001 times.
✓ Branch 3 taken 274701 times.
✓ Branch 4 taken 22001 times.
✗ Branch 5 not taken.
361124 && (attack!=wFire || (candleid!=-1 && !(itemsbuf[candleid].wpn)))
12959
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 274671 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
296702 && (attack!=wCByrna || (byrnaid!=-1 && !(itemsbuf[byrnaid].wpn)))
12960
2/2
✓ Branch 0 taken 296014 times.
✓ Branch 1 taken 21343 times.
274701 && (attack != wBugNet) && attackclk>7))
12961 {
12962
8/8
✓ Branch 0 taken 93657 times.
✓ Branch 1 taken 4745 times.
✓ Branch 2 taken 89110 times.
✓ Branch 3 taken 4547 times.
✓ Branch 4 taken 83924 times.
✓ Branch 5 taken 5186 times.
✓ Branch 6 taken 5631 times.
✓ Branch 7 taken 78293 times.
493626 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))
12963 {
12964 20109 lstep = s;
12965 20109 return false;
12966 }
12967 78293 }
12968
12969
2/2
✓ Branch 0 taken 40923 times.
✓ Branch 1 taken 1611005 times.
1651928 if(charging==0)
12970 {
12971 1611005 lstep=0;
12972 1611005 }
12973
12974 // Work out the sword charge-up delay
12975 1651928 int32_t magiccharge = 192, normalcharge = 64;
12976 1651928 int32_t itemid = current_item_id(itype_chargering);
12977
12978
2/2
✓ Branch 0 taken 1600732 times.
✓ Branch 1 taken 51196 times.
1651928 if(itemid>=0)
12979 {
12980
1/2
✓ Branch 0 taken 51196 times.
✗ Branch 1 not taken.
51196 normalcharge = (itemsbuf[itemid].misc1>0)?itemsbuf[itemid].misc1:64;
12981
1/2
✓ Branch 0 taken 51196 times.
✗ Branch 1 not taken.
51196 magiccharge = (itemsbuf[itemid].misc2>normalcharge)?itemsbuf[itemid].misc2:192;
12982 51196 }
12983
12984 1651928 int scrollid = current_item_id(attack==wHammer ? itype_quakescroll : itype_spinscroll);
12985 1651928 int scroll2id = current_item_id(attack==wHammer ? itype_quakescroll2 : itype_spinscroll2);
12986
12987 1651928 bool doCharge=true;
12988
3/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 1651778 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 150 times.
1651928 if(z!=0 && fakez != 0)
12989 doCharge=false;
12990
2/2
✓ Branch 0 taken 1262282 times.
✓ Branch 1 taken 389646 times.
1651928 if(attack==wSword)
12991 {
12992
4/4
✓ Branch 0 taken 34916 times.
✓ Branch 1 taken 1227366 times.
✓ Branch 2 taken 613 times.
✓ Branch 3 taken 34303 times.
1262282 if(!(attackclk==SWORDCHARGEFRAME && isWpnPressed(itype_sword)))
12993 1227979 doCharge=false;
12994
2/2
✓ Branch 0 taken 10820 times.
✓ Branch 1 taken 23483 times.
34303 else if(charging<=normalcharge)
12995 {
12996
3/6
✓ Branch 0 taken 23483 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23483 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23483 times.
✗ Branch 5 not taken.
23483 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
12997 doCharge=false;
12998 23483 }
12999 1262282 }
13000
2/2
✓ Branch 0 taken 64422 times.
✓ Branch 1 taken 325224 times.
389646 else if(attack==wHammer)
13001 {
13002
4/4
✓ Branch 0 taken 2188 times.
✓ Branch 1 taken 62234 times.
✓ Branch 2 taken 1945 times.
✓ Branch 3 taken 243 times.
64422 if(!(attackclk==HAMMERCHARGEFRAME && isWpnPressed(itype_hammer)))
13003 64179 doCharge=false;
13004
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243 times.
243 else if(charging<=normalcharge)
13005 {
13006
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
243 if(scrollid<0 || !(checkbunny(scrollid) && checkmagiccost(scrollid)))
13007 227 doCharge=false;
13008 243 }
13009 64422 }
13010 else
13011 325224 doCharge=false;
13012
13013 // charging up weapon...
13014
2/2
✓ Branch 0 taken 34319 times.
✓ Branch 1 taken 1617609 times.
1651928 if(doCharge)
13015 {
13016 // Increase charging while holding down button.
13017
3/4
✓ Branch 0 taken 34319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2543 times.
✓ Branch 3 taken 31776 times.
34319 if(spins==0 && charging<magiccharge)
13018 31776 charging++;
13019
13020 // Once a charging threshold is reached, play the sound.
13021
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 34145 times.
34319 if(charging==normalcharge)
13022 {
13023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174 times.
174 if(!(itemsbuf[scrollid].flags&item_flag1))
13024 174 paymagiccost(scrollid);
13025 174 sfx(itemsbuf[scrollid].usesound2,pan(x));
13026 174 }
13027
2/2
✓ Branch 0 taken 31708 times.
✓ Branch 1 taken 2437 times.
34145 else if(charging==magiccharge)
13028 {
13029
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2434 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
2437 if(scroll2id>-1 && checkbunny(scroll2id) && checkmagiccost(scroll2id))
13030 {
13031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!(itemsbuf[scroll2id].flags&item_flag1))
13032 3 paymagiccost(scroll2id);
13033 3 charging++; // charging>magiccharge signifies a successful supercharge.
13034 3 sfx(itemsbuf[scroll2id].usesound2,pan(x));
13035 3 }
13036 2437 }
13037 34319 }
13038
3/4
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1617579 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 30 times.
1617609 else if(attack==wCByrna && byrnaid!=-1)
13039 {
13040
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(!(itemsbuf[byrnaid].wpn))
13041 {
13042 attack = wNone;
13043 return startwpn(attackid); // Beam if the Byrna stab animation WASN'T used.
13044 }
13045
13046 30 bool beamcount = false;
13047
13048
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 55 times.
81 for(int32_t i=0; i<Lwpns.Count(); i++)
13049 {
13050 55 weapon *w = ((weapon*)Lwpns.spr(i));
13051
13052
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 4 times.
55 if(w->id==wCByrna)
13053 {
13054 4 beamcount = true;
13055 4 break;
13056 }
13057 51 }
13058
13059 // If beams already deployed, remove them
13060
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
30 if(!attackclk && beamcount)
13061 {
13062 2 return startwpn(attackid); // Remove beams instantly
13063 }
13064
13065 // Otherwise, continue
13066 28 ++attackclk;
13067 28 }
13068 else
13069 {
13070 1617579 ++attackclk;
13071
13072
6/6
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 1613531 times.
✓ Branch 2 taken 785 times.
✓ Branch 3 taken 3263 times.
✓ Branch 4 taken 485 times.
✓ Branch 5 taken 300 times.
1617579 if(attackclk==SWORDCHARGEFRAME && charging>0 && !tapping) //Signifies a tapped enemy
13073 {
13074 300 ++attackclk; // Won't continue charging
13075 300 charging=0;
13076 300 }
13077
13078 // Faster if spinning.
13079
2/2
✓ Branch 0 taken 1614901 times.
✓ Branch 1 taken 2678 times.
1617579 if(spins>0)
13080 2678 ++attackclk;
13081
13082 // Even faster if hurricane spinning.
13083
2/2
✓ Branch 0 taken 1617147 times.
✓ Branch 1 taken 432 times.
1617579 if(spins>5)
13084 432 attackclk+=2;
13085
13086 // If at a charging threshold, do a charged attack.
13087
5/6
✓ Branch 0 taken 2332 times.
✓ Branch 1 taken 1615247 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2217 times.
✓ Branch 5 taken 115 times.
1617579 if(charging>=normalcharge && (attack!=wSword || attackclk>=SWORDCHARGEFRAME) && !tapping)
13088 {
13089
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(attack==wSword)
13090 {
13091
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3 times.
115 bool super = charging>magiccharge && scroll2id > -1;
13092
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 112 times.
115 int id = super ? scroll2id : scrollid;
13093 115 itemdata const& spinscroll = itemsbuf[id];
13094 115 bool paid = !(spinscroll.flags&item_flag1);
13095
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
115 if(!paid && checkbunny(id) && checkmagiccost(id))
13096 {
13097 paid = true;
13098 paymagiccost(id);
13099 }
13100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(paid)
13101 {
13102 115 currentscroll = id;
13103 115 spins=(spinscroll.misc1*4) + (super ? -3 : 1);
13104 115 attackclk=1;
13105
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 114 times.
115 if(!get_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS))
13106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
2 if(weapon* w = find_first_wtype(wSword))
13107 1 w->reset_wgrids();
13108 115 sfx(spinscroll.usesound,pan(x));
13109
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(spinscroll.flags&item_flag1)
13110 paymagiccost(id);
13111 115 }
13112 115 }
13113 else if(attack==wHammer && sideviewhammerpound())
13114 {
13115 bool super = charging>magiccharge && scroll2id > -1;
13116 int id = super ? scroll2id : scrollid;
13117 itemdata const& quakescroll = itemsbuf[id];
13118 bool paid = !(quakescroll.flags&item_flag1);
13119 if(!paid && checkbunny(id) && checkmagiccost(id))
13120 {
13121 paid = true;
13122 paymagiccost(id);
13123 }
13124 if(paid)
13125 {
13126 currentscroll = id;
13127 spins = super ? 2 : 1;
13128 sfx(quakescroll.usesound,pan(x));
13129 quakeclk=quakescroll.misc1;
13130
13131 // general area stun
13132 for(int32_t i=0; i<GuyCount(); i++)
13133 {
13134 if(!isflier(GuyID(i)))
13135 {
13136 StunGuy(i,quakescroll.misc2-distance(x,y,GuyX(i),GuyY(i)));
13137 }
13138 }
13139
13140 int hmrid = (directWpn>-1 && itemsbuf[directWpn].type==itype_hammer) ? directWpn : current_item_id(itype_hammer);
13141 int hmrlvl = hmrid < 0 ? 1 : itemsbuf[hmrid].level;
13142 if(hmrlvl < 1) hmrlvl = 1;
13143 int rad = quakescroll.misc2;
13144 for_every_combo([&](const auto& handle) {
13145 auto [cx, cy] = handle.xy();
13146 if (distance(x, y, cx, cy) > rad)
13147 return;
13148
13149 vector<int> trigflags = {TRIGFLAG_QUAKESTUN};
13150 if(super) trigflags.push_back(TRIGFLAG_SQUAKESTUN);
13151 trig_each_combo_trigger(handle, [&](combo_trigger const& trig){
13152 if(!trig.trigger_flags.any(trigflags)) return false;
13153 return (trig.trigger_flags.get(TRIGFLAG_INVERTMINMAX)
13154 ? hmrlvl <= trig.triggerlevel : hmrlvl >= trig.triggerlevel);
13155 });
13156 });
13157 }
13158 }
13159 115 }
13160
6/6
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 1613393 times.
✓ Branch 2 taken 3586 times.
✓ Branch 3 taken 485 times.
✓ Branch 4 taken 347 times.
✓ Branch 5 taken 3239 times.
1617464 else if(tapping && attackclk<SWORDCHARGEFRAME && charging<magiccharge)
13161 3239 charging++;
13162
13163
7/8
✓ Branch 0 taken 21601 times.
✓ Branch 1 taken 1595978 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1595978 times.
✓ Branch 4 taken 25736 times.
✓ Branch 5 taken 1570242 times.
✓ Branch 6 taken 907657 times.
✓ Branch 7 taken 709922 times.
1617579 if(!isWpnPressed(attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword))
13164 709922 charging=0;
13165
13166
2/2
✓ Branch 0 taken 1589791 times.
✓ Branch 1 taken 27788 times.
1617579 if(attackclk>=SWORDCHARGEFRAME)
13167 27788 tapping = false;
13168 }
13169
13170
7/8
✓ Branch 0 taken 125960 times.
✓ Branch 1 taken 1525966 times.
✓ Branch 2 taken 1805 times.
✓ Branch 3 taken 124155 times.
✓ Branch 4 taken 1805 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47 times.
✓ Branch 7 taken 1758 times.
1651926 if(attackclk==1 && attack==wFire && candleid!=-1 && !(itemsbuf[candleid].wpn))
13171 {
13172 1758 return startwpn(attackid); // Flame if the Candle stab animation WASN'T used.
13173 }
13174
13175 1650168 int32_t crossid = current_item_id(itype_crossscroll); //has Cross Beams scroll
13176
13177
11/14
✓ Branch 0 taken 1549846 times.
✓ Branch 1 taken 100322 times.
✓ Branch 2 taken 114498 times.
✓ Branch 3 taken 1435348 times.
✓ Branch 4 taken 450 times.
✓ Branch 5 taken 114048 times.
✓ Branch 6 taken 450 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✓ Branch 9 taken 438 times.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
1650168 if(attackclk==13 || (attackclk==7 && spins>1 && attack != wHammer && crossid >=0 && checkbunny(crossid) && checkmagiccost(crossid)))
13178 {
13179
13180
4/4
✓ Branch 0 taken 18502 times.
✓ Branch 1 taken 81832 times.
✓ Branch 2 taken 14966 times.
✓ Branch 3 taken 3536 times.
100334 int32_t wpnid = (directWpn>-1 && itemsbuf[directWpn].type==itype_sword) ? directWpn : current_item_id(itype_sword);
13181
2/2
✓ Branch 0 taken 99931 times.
✓ Branch 1 taken 403 times.
100334 int64_t templife = wpnid>=0? itemsbuf[wpnid].misc1 : 0;
13182
13183
4/4
✓ Branch 0 taken 99931 times.
✓ Branch 1 taken 403 times.
✓ Branch 2 taken 27091 times.
✓ Branch 3 taken 72840 times.
100334 if(wpnid>=0 && itemsbuf[wpnid].flags & item_flag1)
13184 {
13185 72840 templife=templife*game->get_maxlife();
13186 72840 templife=templife/100;
13187 72840 }
13188 else
13189 {
13190 27494 templife*=game->get_hp_per_heart();
13191 }
13192
13193
2/2
✓ Branch 0 taken 37146 times.
✓ Branch 1 taken 63188 times.
100334 bool normalbeam = (int64_t(game->get_life())+(get_qr(qr_QUARTERHEART)?((game->get_hp_per_heart()/4)-1):((game->get_hp_per_heart()/2)-1))>=templife);
13194 100334 int32_t perilid = current_item_id(itype_perilscroll);
13195
3/4
✓ Branch 0 taken 7511 times.
✓ Branch 1 taken 92823 times.
✓ Branch 2 taken 7511 times.
✗ Branch 3 not taken.
100405 bool perilbeam = (perilid>=0 && wpnid>=0 && game->get_life()<=itemsbuf[perilid].misc1*game->get_hp_per_heart()
13196
3/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 7440 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
7511 && checkbunny(perilid) && checkmagiccost(perilid)
13197 // Must actually be able to shoot sword beams
13198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71 times.
71 && ((itemsbuf[wpnid].flags & item_flag1)
13199
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 70 times.
71 || itemsbuf[wpnid].misc1 <= game->get_maxlife()/game->get_hp_per_heart()));
13200
13201
4/4
✓ Branch 0 taken 85190 times.
✓ Branch 1 taken 15144 times.
✓ Branch 2 taken 531 times.
✓ Branch 3 taken 84659 times.
100334 if(attack==wSword && !tapping)
13202 {
13203
4/4
✓ Branch 0 taken 84590 times.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 20024 times.
✓ Branch 3 taken 64566 times.
84659 if(perilbeam || normalbeam)
13204 {
13205
1/2
✓ Branch 0 taken 20093 times.
✗ Branch 1 not taken.
20093 if(attackclk==7)
13206 paymagiccost(crossid); // Pay the Cross Beams magic cost.
13207
13208
3/4
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 20024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69 times.
20093 if(perilbeam && !normalbeam)
13209 69 paymagiccost(perilid); // Pay the Peril Beam magic cost.
13210
13211 // TODO: Something that would be cheap but disgraceful to hack in at this point is
13212 // a way to make the peril/cross beam item's power stat influence the strength
13213 // of the peril/cross beam...
13214 20093 startwpn(attackid);
13215 20093 }
13216 64566 else misc_internal_hero_flags &= ~LF_PAID_SWORD_COST;
13217 84659 }
13218
13219
2/2
✓ Branch 0 taken 98497 times.
✓ Branch 1 taken 1837 times.
100334 if(attack==wWand)
13220 1837 startwpn(attackid); // Flame if the Wand stab animation WAS used (it always is).
13221
13222
5/6
✓ Branch 0 taken 1306 times.
✓ Branch 1 taken 99028 times.
✓ Branch 2 taken 1306 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1259 times.
✓ Branch 5 taken 47 times.
100334 if(attack==wFire && candleid!=-1 && itemsbuf[candleid].wpn) // Flame if the Candle stab animation WAS used.
13223 47 startwpn(attackid);
13224
13225
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 100332 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
100334 if(attack==wCByrna && byrnaid!=-1 && itemsbuf[byrnaid].wpn) // Beam if the Byrna stab animation WAS used.
13226 2 startwpn(attackid);
13227 100334 }
13228
13229
2/2
✓ Branch 0 taken 1550729 times.
✓ Branch 1 taken 99439 times.
1650168 if(attackclk==14)
13230 99439 lstep = s;
13231
13232 1650168 return true;
13233 1770881 }
13234
13235 27148962 bool HeroClass::can_attack()
13236 {
13237
4/4
✓ Branch 0 taken 10820 times.
✓ Branch 1 taken 27138142 times.
✓ Branch 2 taken 2880 times.
✓ Branch 3 taken 7940 times.
27148962 if(lift_wpn && (liftflags & LIFTFL_DIS_ITEMS))
13238 7940 return false;
13239
4/4
✓ Branch 0 taken 26816644 times.
✓ Branch 1 taken 324378 times.
✓ Branch 2 taken 18162254 times.
✓ Branch 3 taken 8654390 times.
27141022 int32_t currentSwordOrWand = (itemsbuf[dowpn].type == itype_wand || itemsbuf[dowpn].type == itype_sword)?dowpn:-1;
13240
4/6
✓ Branch 0 taken 27141022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26873928 times.
✓ Branch 3 taken 267094 times.
✓ Branch 4 taken 26873928 times.
✗ Branch 5 not taken.
28547262 if(action==hopping || action==swimming || action==freeze || action==sideswimfreeze
13241
5/8
✓ Branch 0 taken 26873928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26873928 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26873928 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 26867020 times.
✓ Branch 7 taken 6908 times.
26873928 || lstunclock > 0 || is_conveyor_stunned || spins>0 || usingActiveShield()
13242
3/4
✓ Branch 0 taken 26867020 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23526863 times.
✓ Branch 3 taken 3340157 times.
26867020 || ((action==attacking||action==sideswimattacking)
13243
2/2
✓ Branch 0 taken 742134 times.
✓ Branch 1 taken 26124886 times.
26867020 && ((attack!=wSword && attack!=wWand) || !(itemsbuf[currentSwordOrWand].flags & item_flag5))
13244
2/2
✓ Branch 0 taken 26788992 times.
✓ Branch 1 taken 664106 times.
26867020 && charging!=0))
13245 {
13246 1680242 return false;
13247 }
13248
13249 26788992 int32_t r = (isdungeon()) ? 16 : 0;
13250 26788992 int32_t r2 = get_qr(qr_NOBORDER) ? 0 : 8;
13251
13252
4/5
✓ Branch 0 taken 7557878 times.
✓ Branch 1 taken 19231114 times.
✓ Branch 2 taken 8488934 times.
✓ Branch 3 taken 10742180 times.
✗ Branch 4 not taken.
26788992 if(!get_qr(qr_ITEMSONEDGES)) switch(dir)
13253 {
13254 case up:
13255 case down:
13256
2/2
✓ Branch 0 taken 8188910 times.
✓ Branch 1 taken 300024 times.
8488934 return !(y<(r2+r) || y>(world_h-16-r-r2));
13257
13258 case left:
13259 case right:
13260
2/2
✓ Branch 0 taken 10453168 times.
✓ Branch 1 taken 289012 times.
10742180 return !(x<(r2+r) || x>(world_w-16-r-r2));
13261 }
13262
13263 7557878 return true;
13264 28477174 }
13265
13266 16775 bool isRaftFlag(int32_t flag)
13267 {
13268
4/4
✓ Branch 0 taken 8791 times.
✓ Branch 1 taken 7984 times.
✓ Branch 2 taken 255 times.
✓ Branch 3 taken 8536 times.
16775 return (flag==mfRAFT || flag==mfRAFT_BRANCH || flag==mfRAFT_BOUNCE);
13269 }
13270
13271 7642157 void handle_lens_triggers(int32_t l_id)
13272 {
13273
2/2
✓ Branch 0 taken 7635874 times.
✓ Branch 1 taken 6283 times.
7642157 bool enabled = l_id >= 0 && (itemsbuf[l_id].flags & item_flag6);
13274 7642157 auto& combo_cache = combo_caches::lens;
13275 3133840652 for_every_combo([&](const auto& handle) {
13276 3126198495 auto cid = handle.data();
13277 3126198495 auto& mini_cmb = combo_cache.minis[cid];
13278
7/8
✓ Branch 0 taken 120384 times.
✓ Branch 1 taken 3123582176 times.
✓ Branch 2 taken 3123702374 times.
✓ Branch 3 taken 186 times.
✓ Branch 4 taken 1596 times.
✓ Branch 5 taken 2494339 times.
✓ Branch 6 taken 2495935 times.
✗ Branch 7 not taken.
3126198495 if (!(enabled ? mini_cmb.on : mini_cmb.off))
13279 3126198309 return;
13280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
372 trig_each_combo_trigger(handle, [&](combo_trigger const& trig){
13281 186 return trig.trigger_flags.get(enabled ? TRIGFLAG_LENSON : TRIGFLAG_LENSOFF);
13282 });
13283 3126198495 });
13284 7642157 }
13285
13286 13705682 void do_lens()
13287 {
13288
2/2
✓ Branch 0 taken 6063525 times.
✓ Branch 1 taken 7642157 times.
13705682 if ( FFCore.getQuestHeaderInfo(vZelda) < 0x250 ) //2.10 or earlier
13289 {
13290 6063525 do_210_lens();
13291 6063525 return;
13292 }
13293
13294 7642157 int32_t wpnPressed = getWpnPressed(itype_lens);
13295
6/6
✓ Branch 0 taken 6280 times.
✓ Branch 1 taken 7635877 times.
✓ Branch 2 taken 376 times.
✓ Branch 3 taken 7635501 times.
✓ Branch 4 taken 391205 times.
✓ Branch 5 taken 7244296 times.
7642157 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>0 ? wpnPressed : Hero.getLastLensID()>0 ? Hero.getLastLensID() : current_item_id(itype_lens);
13296
3/4
✓ Branch 0 taken 7635877 times.
✓ Branch 1 taken 6280 times.
✓ Branch 2 taken 7635877 times.
✗ Branch 3 not taken.
7642157 if (lensid < 0 && Hero.on_cooldown(itemid))
13297 itemid = -1;
13298
2/2
✓ Branch 0 taken 6085161 times.
✓ Branch 1 taken 1556996 times.
7642157 if(itemid >= 0)
13299 {
13300
8/10
✓ Branch 0 taken 5364 times.
✓ Branch 1 taken 1551632 times.
✓ Branch 2 taken 5364 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 695 times.
✓ Branch 5 taken 4669 times.
✓ Branch 6 taken 695 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 166 times.
✓ Branch 9 taken 529 times.
1556996 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkbunny(itemid) && checkmagiccost(itemid))
13301 {
13302
2/2
✓ Branch 0 taken 319 times.
✓ Branch 1 taken 210 times.
529 if(lensid<0)
13303 {
13304 210 lensid = itemid;
13305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 210 times.
210 if(itemsbuf[itemid].type == itype_lens)
13306 210 Hero.setLastLensID(itemid);
13307
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 13 times.
210 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
13308 210 }
13309
13310 529 paymagiccost(itemid, true); //Needs to ignore timer cause lensclk is our timer.
13311
13312
2/10
✓ Branch 0 taken 529 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 529 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
529 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
13313 {
13314 //clear the item script stack for a new script
13315 int i = itemid;
13316 FFCore.reset_script_engine_data(ScriptType::Item, i);
13317 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13318 did_scriptl=true;
13319 }
13320
13321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 529 times.
529 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
13322 529 else lensclk = 12;
13323 529 }
13324 else
13325 {
13326 1556467 did_scriptl=false;
13327
2/2
✓ Branch 0 taken 1550713 times.
✓ Branch 1 taken 5754 times.
1556467 if(!lensclk)
13328 {
13329
13330
2/2
✓ Branch 0 taken 1550506 times.
✓ Branch 1 taken 207 times.
1550713 if(lensid > -1)
13331 {
13332 207 Hero.start_cooldown(lensid);
13333 207 lensid = -1;
13334 207 lensclk = 0;
13335
13336
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 12 times.
207 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
13337 207 }
13338 1550713 }
13339 }
13340 1556996 }
13341 7642157 handle_lens_triggers(lensid);
13342 13705682 }
13343
13344 6063525 void do_210_lens()
13345 {
13346 6063525 int32_t wpnPressed = getWpnPressed(itype_lens);
13347
4/4
✓ Branch 0 taken 3334 times.
✓ Branch 1 taken 6060191 times.
✓ Branch 2 taken 487 times.
✓ Branch 3 taken 6059704 times.
6063525 int32_t itemid = lensid >= 0 ? lensid : wpnPressed>-1 ? wpnPressed : current_item_id(itype_lens);
13348
2/2
✓ Branch 0 taken 1226986 times.
✓ Branch 1 taken 4836539 times.
6063525 if(itemid<0)
13349 4836539 return;
13350
13351
7/8
✓ Branch 0 taken 3343 times.
✓ Branch 1 taken 1223643 times.
✓ Branch 2 taken 3343 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 2821 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 515 times.
1226986 if(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && !lensclk && checkmagiccost(itemid))
13352 {
13353
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 480 times.
515 if(lensid<0)
13354 {
13355 480 lensid=itemid;
13356
13357
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(get_qr(qr_MORESOUNDS)) sfx(itemsbuf[itemid].usesound);
13358 480 }
13359
13360 515 paymagiccost(itemid, true);
13361
13362
2/10
✓ Branch 0 taken 515 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 515 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
515 if(itemid>=0 && itemsbuf[itemid].script != 0 && !did_scriptl && !(FFCore.doscript(ScriptType::Item, itemid) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
13363 {
13364 //clear the item script stack for a new script
13365 int i = itemid;
13366 FFCore.reset_script_engine_data(ScriptType::Item, i);
13367 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
13368 did_scriptl=true;
13369 }
13370
13371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 515 times.
515 if (itemsbuf[itemid].magiccosttimer[0]) lensclk = itemsbuf[itemid].magiccosttimer[0];
13372 515 else lensclk = 12;
13373 515 }
13374 else
13375 {
13376 1226471 did_scriptl=false;
13377
13378
7/8
✓ Branch 0 taken 3299 times.
✓ Branch 1 taken 1223172 times.
✓ Branch 2 taken 2821 times.
✓ Branch 3 taken 478 times.
✓ Branch 4 taken 2821 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2820 times.
✓ Branch 7 taken 1 times.
1226471 if(lensid>-1 && !(isWpnPressed(itype_lens) && checkitem_jinx(itemid) && checkmagiccost(itemid)))
13379 {
13380 479 lensid=-1;
13381 479 lensclk = 0;
13382
13383
1/2
✓ Branch 0 taken 479 times.
✗ Branch 1 not taken.
479 if(get_qr(qr_MORESOUNDS)) sfx(WAV_ZN1LENSOFF);
13384 479 }
13385 }
13386 6063525 }
13387
13388 14081 void HeroClass::do_hopping()
13389 {
13390 14081 do_lens();
13391
13392
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 13527 times.
14081 if(hopclk==0xFF) //|| (diagonalMovement && hopclk >= 0xFF) )) // swimming
13393 //Possible fix for exiting water in diagonal movement. -Z
13394 {
13395 554 int32_t flippers_id = current_item_id(itype_flippers);
13396
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 550 times.
554 if(diveclk>0)
13397 {
13398 4 --diveclk;
13399
2/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if (flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag2 && getInput(btnA, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION)) //Cancellable Diving -Em
13400 {
13401 diveclk = itemsbuf[flippers_id].misc2;
13402 }
13403 4 }
13404
2/2
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 2 times.
550 else if (getInput(btnA, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
13405 {
13406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag1);
13407 2 bool screen_diving=(hero_scr->flags5&fTOGGLEDIVING) != 0;
13408
13409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(global_diving==screen_diving)
13410
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
13411 2 }
13412
13413
6/8
✓ Branch 0 taken 427 times.
✓ Branch 1 taken 127 times.
✓ Branch 2 taken 156 times.
✓ Branch 3 taken 398 times.
✓ Branch 4 taken 156 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 156 times.
554 if((!(x.getInt()&7) && !(y.getInt()&7)) || (diagonalMovement||NO_GRIDLOCK))
13414 {
13415 398 SetSwim();
13416 398 hopclk = 0;
13417
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 398 times.
398 if (!IsSideSwim())
13418 {
13419 398 charging = attackclk = 0;
13420 398 tapping = false;
13421 398 }
13422 398 }
13423 else
13424 {
13425 156 herostep();
13426
13427
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
156 if(!isDiving() || (frame&1))
13428 {
13429
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 30 times.
✓ Branch 4 taken 77 times.
156 switch(dir)
13430 {
13431 case up:
13432 42 y -= 1;
13433 42 break;
13434
13435 case down:
13436 7 y += 1;
13437 7 break;
13438
13439 case left:
13440 30 x -= 1;
13441 30 break;
13442
13443 case right:
13444 77 x += 1;
13445 77 break;
13446 }
13447 156 }
13448 }
13449 554 }
13450 else // hopping in or out (need to separate the cases...)
13451 {
13452
4/6
✓ Branch 0 taken 12509 times.
✓ Branch 1 taken 1018 times.
✓ Branch 2 taken 12509 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12509 times.
13527 if((diagonalMovement||NO_GRIDLOCK))
13453 {
13454
2/2
✓ Branch 0 taken 643 times.
✓ Branch 1 taken 375 times.
1018 if(hopclk==1) //hopping out
13455 //>= 1 possible fix for getting stuck on land edges.
13456 //No, this is not a clock. it's a type. 1 == out, 2 == in.
13457 {
13458
1/2
✓ Branch 0 taken 375 times.
✗ Branch 1 not taken.
375 if(hopdir!=-1) dir=hopdir;
13459
13460 375 landswim=0;
13461
13462
2/2
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 101 times.
375 if(dir==up)
13463 {
13464 101 herostep();
13465 101 herostep();
13466 101 int32_t sidestep=0;
13467
13468
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 101 times.
101 if(iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)-1), -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), -1, x+8,y+(bigHitbox?0:8)-1, true, false) && !iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13469 sidestep=1;
13470
3/6
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101 times.
✗ Branch 5 not taken.
101 else if(!iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)-1), -1, x,y+(bigHitbox?0:8)-1, true, false) && !iswaterex_z3(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), -1, x+7,y+(bigHitbox?0:8)-1, true, false) && iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13471 sidestep=2;
13472
13473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if(sidestep==1) x++;
13474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 else if(sidestep==2) x--;
13475 101 else y--;
13476
13477
3/4
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 8 times.
101 if(!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+15), -1, x.getInt(),y.getInt()+15, true, false))
13478 {
13479 8 hopclk=0;
13480 8 diveclk=0;
13481 8 action=none; FFCore.setHeroAction(none);
13482 8 hopdir=-1;
13483 8 }
13484 101 }
13485
13486
2/2
✓ Branch 0 taken 303 times.
✓ Branch 1 taken 72 times.
375 if(dir==down)
13487 {
13488 72 herostep();
13489 72 herostep();
13490 72 int32_t sidestep=0;
13491
13492
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 72 times.
72 if(iswaterex_z3(MAPCOMBO(x,y+16), -1, x,y+16, true, false) && !iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16, true, false) && !iswaterex_z3(MAPCOMBO(x+15,y+16), -1, x+15,y+16, true, false))
13493 sidestep=1;
13494
3/6
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 72 times.
✗ Branch 5 not taken.
72 else if(!iswaterex_z3(MAPCOMBO(x,y+16), -1, x,y+16, true, false) && !iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16, true, false) && iswaterex_z3(MAPCOMBO(x+15,y+16), -1, x+15,y+16, true, false))
13495 sidestep=2;
13496
13497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 if(sidestep==1) x++;
13498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
72 else if(sidestep==2) x--;
13499 72 else y++;
13500
13501
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
72 if(!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+15), -1, x.getInt(),y.getInt()+15, true, false))
13502 {
13503 6 hopclk=0;
13504 6 diveclk=0;
13505 6 action=none; FFCore.setHeroAction(none);
13506 6 hopdir=-1;
13507 6 }
13508 72 }
13509
13510
2/2
✓ Branch 0 taken 318 times.
✓ Branch 1 taken 57 times.
375 if(dir==left)
13511 {
13512 57 herostep();
13513 57 herostep();
13514 57 int32_t sidestep=0;
13515
13516
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
57 if(iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?0:8)), -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?8:12)), -1, x-1,y+(bigHitbox?8:12), true, false) && !iswaterex_z3(MAPCOMBO(x-1,y+15), -1, x-1,y+15, true, false))
13517 sidestep=1;
13518
3/6
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 57 times.
✗ Branch 5 not taken.
57 else if(!iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?0:8)), -1, x-1,y+(bigHitbox?0:8), true, false) && !iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?7:11)), -1, x-1,y+(bigHitbox?7:11), true, false) && iswaterex_z3(MAPCOMBO(x-1,y+15), -1, x-1,y+15, true, false))
13519 sidestep=2;
13520
13521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(sidestep==1) y++;
13522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 else if(sidestep==2) y--;
13523 57 else x--;
13524
13525
3/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 4 times.
57 if(!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex_z3(MAPCOMBO(x.getInt()+15,y.getInt()+8), -1, x.getInt()+15,y.getInt()+8, true, false))
13526 {
13527 4 hopclk=0;
13528 4 diveclk=0;
13529 4 action=none; FFCore.setHeroAction(none);
13530 4 hopdir=-1;
13531 4 }
13532 57 }
13533
13534
2/2
✓ Branch 0 taken 230 times.
✓ Branch 1 taken 145 times.
375 if(dir==right)
13535 {
13536 145 herostep();
13537 145 herostep();
13538 145 int32_t sidestep=0;
13539
13540
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 145 times.
145 if(iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?0:8)), -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?8:12)), -1, x+16,y+(bigHitbox?8:12), true, false) && !iswaterex_z3(MAPCOMBO(x+16,y+15), -1, x+16,y+15, true, false))
13541 sidestep=1;
13542
3/6
✓ Branch 0 taken 145 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 145 times.
✗ Branch 5 not taken.
145 else if(!iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?0:8)), -1, x+16,y+(bigHitbox?0:8), true, false) && !iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?7:11)), -1, x+16,y+(bigHitbox?7:11), true, false) && iswaterex_z3(MAPCOMBO(x+16,y+15), -1, x+16,y+15, true, false))
13543 sidestep=2;
13544
13545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 if(sidestep==1) y++;
13546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 145 times.
145 else if(sidestep==2) y--;
13547 145 else x++;
13548
13549
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 134 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
145 if(!iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&!iswaterex_z3(MAPCOMBO(x.getInt()+15,y.getInt()+8), -1, x.getInt()+15,y.getInt()+8, true, false))
13550 {
13551 11 hopclk=0;
13552 11 diveclk=0;
13553 11 action=none; FFCore.setHeroAction(none);
13554 11 hopdir=-1;
13555 11 }
13556 145 }
13557 375 }
13558
13559
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 643 times.
1018 if(hopclk==2) //hopping in
13560 {
13561 643 landswim=0;
13562
13563
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 89 times.
643 if(dir==up)
13564 {
13565 89 herostep();
13566 89 herostep();
13567 89 int32_t sidestep=0;
13568
13569
6/6
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 49 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 39 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 88 times.
89 if(!iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)-1), -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), -1, x+8,y+(bigHitbox?0:8)-1, true, false) && iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13570 1 sidestep=1;
13571
4/6
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 39 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 49 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
88 else if(iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)-1), -1, x,y+(bigHitbox?0:8)-1, true, false) && iswaterex_z3(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), -1, x+7,y+(bigHitbox?0:8)-1, true, false) && !iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)-1), -1, x+15,y+(bigHitbox?0:8)-1, true, false))
13572 sidestep=2;
13573
13574
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 88 times.
89 if(sidestep==1) x++;
13575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 88 times.
88 else if(sidestep==2) x--;
13576 88 else y--;
13577
13578
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 4 times.
89 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+15), -1, x.getInt(),y.getInt()+15, true, false))
13579 {
13580 4 hopclk=0xFF;
13581 4 diveclk=0;
13582 4 SetSwim();
13583 4 }
13584 89 }
13585
13586
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 142 times.
643 if(dir==down)
13587 {
13588 142 herostep();
13589 142 herostep();
13590 142 int32_t sidestep=0;
13591
13592
3/6
✓ Branch 0 taken 142 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 142 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 142 times.
142 if(!iswaterex_z3(MAPCOMBO(x,y+16), -1, x,y+16, true, false) && iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16, true, false) && iswaterex_z3(MAPCOMBO(x+15,y+16), -1, x+15,y+16, true, false))
13593 sidestep=1;
13594
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 142 times.
✗ Branch 5 not taken.
142 else if(iswaterex_z3(MAPCOMBO(x,y+16), -1, x,y+16, true, false) && iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16, true, false) && !iswaterex_z3(MAPCOMBO(x+15,y+16), -1, x+15,y+16, true, false))
13595 sidestep=2;
13596
13597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if(sidestep==1) x++;
13598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if(sidestep==2) x--;
13599 142 else y++;
13600
13601
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
142 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+15), -1, x.getInt(),y.getInt()+15, true, false))
13602 {
13603 hopclk=0xFF;
13604 diveclk=0;
13605 SetSwim();
13606 if (!IsSideSwim()) reset_swordcharge();
13607 }
13608 142 }
13609
13610
2/2
✓ Branch 0 taken 510 times.
✓ Branch 1 taken 133 times.
643 if(dir==left)
13611 {
13612 133 herostep();
13613 133 herostep();
13614 133 int32_t sidestep=0;
13615
13616
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if(!iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?0:8)), -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?8:12)), -1, x-1,y+(bigHitbox?8:12), true, false) && iswaterex_z3(MAPCOMBO(x-1,y+15), -1, x-1,y+15, true, false))
13617 sidestep=1;
13618
4/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
133 else if(iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?0:8)), -1, x-1,y+(bigHitbox?0:8), true, false) && iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?7:11)), -1, x-1,y+(bigHitbox?7:11), true, false) && !iswaterex_z3(MAPCOMBO(x-1,y+15), -1, x-1,y+15, true, false))
13619 sidestep=2;
13620
13621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(sidestep==1) y++;
13622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 else if(sidestep==2) y--;
13623 133 else x--;
13624
13625
4/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 95 times.
133 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex_z3(MAPCOMBO(x.getInt()+15,y.getInt()+8), -1, x.getInt()+15,y.getInt()+8, true, false))
13626 {
13627 7 hopclk=0xFF;
13628 7 diveclk=0;
13629 7 SetSwim();
13630 7 }
13631 133 }
13632
13633
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 279 times.
643 if(dir==right)
13634 {
13635 279 herostep();
13636 279 herostep();
13637
13638 279 int32_t sidestep=0;
13639
13640
4/6
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 279 times.
279 if(!iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?0:8)), -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?8:12)), -1, x+16,y+(bigHitbox?8:12), true, false) && iswaterex_z3(MAPCOMBO(x+16,y+15), -1, x+16,y+15, true, false))
13641 sidestep=1;
13642
4/6
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72 times.
✓ Branch 4 taken 279 times.
✗ Branch 5 not taken.
279 else if(iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?0:8)), -1, x+16,y+(bigHitbox?0:8), true, false) && iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?7:11)), -1, x+16,y+(bigHitbox?7:11), true, false) && !iswaterex_z3(MAPCOMBO(x+16,y+15), -1, x+16,y+15, true, false))
13643 sidestep=2;
13644
13645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(sidestep==1) y++;
13646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 else if(sidestep==2) y--;
13647 279 else x++;
13648
13649
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
279 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+(bigHitbox?0:8)), -1, x.getInt(),y.getInt()+(bigHitbox?0:8), true, false)&&iswaterex_z3(MAPCOMBO(x.getInt()+15,y.getInt()+8), -1, x.getInt()+15,y.getInt()+8, true, false))
13650 {
13651 5 hopclk=0xFF;
13652 5 diveclk=0;
13653 5 SetSwim();
13654 5 }
13655 279 }
13656 643 }
13657
13658 1018 }
13659 else
13660 {
13661
7/8
✓ Branch 0 taken 4823 times.
✓ Branch 1 taken 7686 times.
✓ Branch 2 taken 4823 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3622 times.
✓ Branch 5 taken 1201 times.
✓ Branch 6 taken 640 times.
✓ Branch 7 taken 7046 times.
12509 if((dir<left ? !(x.getInt()&7) && !(y.getInt()&15) : !(x.getInt()&15) && !(y.getInt()&7)))
13662 {
13663 1201 action=none; FFCore.setHeroAction(none);
13664 1201 hopclk = 0;
13665 1201 diveclk = 0;
13666
13667
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 625 times.
1201 if(iswaterex_z3(MAPCOMBO(x.getInt(),y.getInt()+8), -1, x.getInt(),y.getInt()+8, true, false))
13668 {
13669 // hopped in
13670 625 SetSwim();
13671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 625 times.
625 if (!IsSideSwim()) attackclk = charging = spins = 0;
13672 625 }
13673 1201 }
13674 else
13675 {
13676 11308 herostep();
13677 11308 herostep();
13678
13679
2/2
✓ Branch 0 taken 10642 times.
✓ Branch 1 taken 666 times.
11308 if(++hero_count>(16*hero_animation_speed))
13680 666 hero_count=0;
13681
13682 11308 int32_t xofs2 = x.getInt()&15;
13683 11308 int32_t yofs2 = y.getInt()&15;
13684 11308 int32_t s = 1 + (frame&1);
13685
13686
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✓ Branch 2 taken 2606 times.
✓ Branch 3 taken 3402 times.
✓ Branch 4 taken 3644 times.
11308 switch(dir)
13687 {
13688 case up:
13689
4/4
✓ Branch 0 taken 1173 times.
✓ Branch 1 taken 483 times.
✓ Branch 2 taken 1167 times.
✓ Branch 3 taken 6 times.
1656 if(yofs2<3 || yofs2>13) --y;
13690 1167 else y-=s;
13691
13692 1656 break;
13693
13694 case down:
13695
4/4
✓ Branch 0 taken 2152 times.
✓ Branch 1 taken 454 times.
✓ Branch 2 taken 356 times.
✓ Branch 3 taken 1796 times.
2606 if(yofs2<3 || yofs2>13) ++y;
13696 1796 else y+=s;
13697
13698 2606 break;
13699
13700 case left:
13701
4/4
✓ Branch 0 taken 2966 times.
✓ Branch 1 taken 436 times.
✓ Branch 2 taken 598 times.
✓ Branch 3 taken 2368 times.
3402 if(xofs2<3 || xofs2>13) --x;
13702 2368 else x-=s;
13703
13704 3402 break;
13705
13706 case right:
13707
4/4
✓ Branch 0 taken 3009 times.
✓ Branch 1 taken 635 times.
✓ Branch 2 taken 492 times.
✓ Branch 3 taken 2517 times.
3644 if(xofs2<3 || xofs2>13) ++x;
13708 2517 else x+=s;
13709
13710 3644 break;
13711 }
13712 }
13713 }
13714 }
13715 14081 }
13716
13717 113150 void HeroClass::do_rafting()
13718 {
13719
13720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 if(toogam)
13721 {
13722 action=none; FFCore.setHeroAction(none);
13723 return;
13724 }
13725
13726 113150 FFCore.setHeroAction(rafting);
13727
13728 113150 do_lens();
13729
13730 113150 herostep();
13731
13732 //Calculate rafting speed
13733 113150 int32_t raft_item = current_item_id(itype_raft);
13734
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 int32_t raft_step = (raft_item < 0 ? 1 : itemsbuf[raft_item].misc1);
13735 113150 raft_step = vbound(raft_step, -8, 5);
13736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 int32_t raft_time = raft_step < 0 ? 1<<(-raft_step) : 1;
13737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113150 times.
113150 if(raft_step < 0) raft_step = 1;
13738 113150 int32_t step_inc = 1 << (raft_step - 1);
13739 // Fix position
13740
1/2
✓ Branch 0 taken 113150 times.
✗ Branch 1 not taken.
113150 if(raft_step > 1)
13741 {
13742 if(x.getInt() & (step_inc-1))
13743 {
13744 x = x.getInt() & ~(step_inc-1);
13745 }
13746 if(y.getInt() & (step_inc-1))
13747 {
13748 y = y.getInt() & ~(step_inc-1);
13749 }
13750 }
13751 // Inc clock, check if we need to move this frame
13752 113150 ++raftclk;
13753
2/4
✓ Branch 0 taken 113150 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113150 times.
113150 if((raftclk % raft_time) || raft_step == 0) return; //No movement this frame
13754
13755
4/4
✓ Branch 0 taken 54339 times.
✓ Branch 1 taken 58811 times.
✓ Branch 2 taken 46510 times.
✓ Branch 3 taken 7829 times.
120836 if(!(x.getInt()&15) && !(y.getInt()&15))
13756 {
13757 // this sections handles switching to raft branches
13758
3/4
✓ Branch 0 taken 7575 times.
✓ Branch 1 taken 254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7575 times.
7829 if((MAPFLAG(x,y)==mfRAFT_BRANCH||MAPCOMBOFLAG(x,y)==mfRAFT_BRANCH))
13759 {
13760
7/8
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 139 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 35 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
254 if (dir != down && getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && (isRaftFlag(nextflag(x, y, up, false)) || isRaftFlag(nextflag(x, y, up, true))))
13761 {
13762 35 dir = up;
13763 35 goto skip;
13764 }
13765
13766
7/8
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 112 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 48 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 15 times.
219 if (dir != up && getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && (isRaftFlag(nextflag(x, y, down, false)) || isRaftFlag(nextflag(x, y, down, true))))
13767 {
13768 48 dir = down;
13769 48 goto skip;
13770 }
13771
13772
7/8
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 37 times.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 98 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 31 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
171 if (dir != right && getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && (isRaftFlag(nextflag(x, y, left, false)) || isRaftFlag(nextflag(x, y, left, true))))
13773 {
13774 31 dir = left;
13775 31 goto skip;
13776 }
13777
13778
7/8
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 41 times.
✓ Branch 3 taken 85 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12 times.
140 if (dir != left && getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && (isRaftFlag(nextflag(x, y, right, false)) || isRaftFlag(nextflag(x, y, right, true))))
13779 {
13780 29 dir = right;
13781 29 goto skip;
13782 }
13783 111 }
13784
2/4
✓ Branch 0 taken 7575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7575 times.
7575 else if((MAPFLAG(x,y)==mfRAFT_BOUNCE||MAPCOMBOFLAG(x,y)==mfRAFT_BOUNCE))
13785 {
13786 if(dir == left) dir = right;
13787 else if(dir == right) dir = left;
13788 else if(dir == up) dir = down;
13789 else if(dir == down) dir = up;
13790 }
13791
13792
4/4
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 6304 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 1371 times.
7686 if(!isRaftFlag(nextflag(x,y,dir,false))&&!isRaftFlag(nextflag(x,y,dir,true)))
13793 {
13794
2/2
✓ Branch 0 taken 739 times.
✓ Branch 1 taken 632 times.
1371 if(dir<left) //going up or down
13795 {
13796
3/4
✓ Branch 0 taken 470 times.
✓ Branch 1 taken 269 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 470 times.
739 if((isRaftFlag(nextflag(x,y,right,false))||isRaftFlag(nextflag(x,y,right,true))))
13797 269 dir=right;
13798
3/4
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 229 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 241 times.
470 else if((isRaftFlag(nextflag(x,y,left,false))||isRaftFlag(nextflag(x,y,left,true))))
13799 229 dir=left;
13800
4/4
✓ Branch 0 taken 226 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 16 times.
241 else if(y>0 && y<world_h-16)
13801 {
13802 210 action=none; FFCore.setHeroAction(none);
13803 210 x = x.getInt();
13804 210 y = y.getInt();
13805 210 }
13806 739 }
13807 else //going left or right
13808 {
13809
3/4
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 243 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 389 times.
632 if((isRaftFlag(nextflag(x,y,down,false))||isRaftFlag(nextflag(x,y,down,true))))
13810 243 dir=down;
13811
3/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
389 else if((isRaftFlag(nextflag(x,y,up,false))||isRaftFlag(nextflag(x,y,up,true))))
13812 242 dir=up;
13813
4/4
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 145 times.
147 else if(x>0 && x<world_w-16)
13814 {
13815 145 action=none; FFCore.setHeroAction(none);
13816 145 x = x.getInt();
13817 145 y = y.getInt();
13818 145 }
13819 }
13820 1371 }
13821 7686 }
13822
13823 skip:
13824
13825
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 25101 times.
✓ Branch 2 taken 24965 times.
✓ Branch 3 taken 29470 times.
✓ Branch 4 taken 33614 times.
113150 switch(dir)
13826 {
13827 case up:
13828
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 25092 times.
25101 if(x.getInt()&15)
13829 {
13830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(x.getInt()&8)
13831 x++;
13832 9 else x--;
13833 9 }
13834 25092 else y -= step_inc;
13835
13836 25101 break;
13837
13838 case down:
13839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24965 times.
24965 if(x.getInt()&15)
13840 {
13841 if(x.getInt()&8)
13842 x++;
13843 else x--;
13844 }
13845 24965 else y += step_inc;
13846
13847 24965 break;
13848
13849 case left:
13850
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 29464 times.
29470 if(y.getInt()&15)
13851 {
13852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if (get_qr(qr_BETTER_RAFT_2))
13853 {
13854 if ((y.getInt() % 16) < 4) y--;
13855 else y++;
13856 }
13857 else
13858 {
13859
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(y.getInt()&8)
13860 6 y++;
13861 else y--;
13862 }
13863 6 }
13864 29464 else x -= step_inc;
13865
13866 29470 break;
13867
13868 case right:
13869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33614 times.
33614 if(y.getInt()&15)
13870 {
13871 if (get_qr(qr_BETTER_RAFT_2))
13872 {
13873 if ((y.getInt() % 16) <= 4) y--;
13874 else y++;
13875 }
13876 else
13877 {
13878 if(y.getInt()&8)
13879 y++;
13880 else y--;
13881 }
13882 }
13883 33614 else x += step_inc;
13884
13885 33614 break;
13886 }
13887 113150 }
13888
13889 3926 bool HeroClass::tick_hover()
13890 {
13891
2/2
✓ Branch 0 taken 3909 times.
✓ Branch 1 taken 17 times.
3926 if(hoverclk > 0)
13892 {
13893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(hoverflags&HOV_INF) return false;
13894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(is_autowalking()) return false;
13895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if(!--hoverclk)
13896 {
13897 hoverflags |= HOV_OUT | HOV_PITFALL_OUT;
13898 return true;
13899 }
13900 17 }
13901 3926 return false;
13902 3926 }
13903
13904 60618 bool HeroClass::try_hover()
13905 {
13906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60618 times.
60618 if(hoverclk > 0) return false;
13907
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60618 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60618 if(!(is_autowalking() && check_pitslide() != -1))
13908 {
13909
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 60616 times.
60618 if(!can_use_item(itype_hoverboots,i_hoverboots)) return false;
13910
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(ladderx || laddery) return false;
13911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hoverflags & HOV_OUT) return false;
13912 2 }
13913 2 int32_t itemid = current_item_id(itype_hoverboots);
13914
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(hoverclk < 0)
13915 hoverclk = -hoverclk;
13916 else
13917 {
13918 2 fall = fakefall = jumping = 0;
13919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].misc1)
13920 2 hoverclk = itemsbuf[itemid].misc1;
13921 else
13922 {
13923 hoverclk = 1;
13924 hoverflags |= HOV_INF;
13925 }
13926
13927 2 sfx(itemsbuf[itemid].usesound,pan(x));
13928 }
13929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(itemsbuf[itemid].wpn)
13930
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 decorations.add(new dHover(x, y, dHOVER, 0));
13931 2 return true;
13932 60618 }
13933
13934 //Returns bitwise; lower 8 are dir pulled in, next 16 are combo ID, 25th bit is bool for if can be resisted
13935 //Returns '-1' if not being pulled
13936 //Returns '-2' if should be falling in
13937 40394307 int32_t HeroClass::check_pitslide(bool ignore_hover)
13938 {
13939 //Pitfall todo -Emily
13940 //Iron boots; can't fight slipping, 2px/frame
13941 //Scripted variables to read pull dir/clk (clk only for non-hero)
13942 //Implement falling for all sprite types (npc AI)
13943 // Fall/slipping tiles for enemies
13944 // Fall/slipping SFX for enemies
13945 // Fall SFX for items/weapons
13946 // Weapons/Misc sprite shared for falling items/weapons
13947 //Maybe slip SFX for Hero?
13948 // Weapons/Misc sprite override for falling sprite?
13949 //Update std.zh with relevant new stuff
13950
2/2
✓ Branch 0 taken 1202934 times.
✓ Branch 1 taken 39191373 times.
40394307 if(can_pitfall(ignore_hover))
13951 {
13952
3/4
✓ Branch 0 taken 12630755 times.
✓ Branch 1 taken 26560618 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26560618 times.
39191373 bool can_diag = (diagonalMovement || NO_GRIDLOCK);
13953 39191373 int32_t ispitul = getpitfall(x,y+(bigHitbox?0:8));
13954 39191373 int32_t ispitbl = getpitfall(x,y+15);
13955 39191373 int32_t ispitur = getpitfall(x+15,y+(bigHitbox?0:8));
13956 39191373 int32_t ispitbr = getpitfall(x+15,y+15);
13957 39191373 int32_t ispitul_50 = getpitfall(x+8,y+(bigHitbox?8:12));
13958 39191373 int32_t ispitbl_50 = getpitfall(x+8,y+(bigHitbox?7:11));
13959 39191373 int32_t ispitur_50 = getpitfall(x+7,y+(bigHitbox?8:12));
13960 39191373 int32_t ispitbr_50 = getpitfall(x+7,y+(bigHitbox?7:11));
13961 39191373 int32_t ispitul_75 = getpitfall(x+12,y+(bigHitbox?12:14));
13962 39191373 int32_t ispitbl_75 = getpitfall(x+12,y+(bigHitbox?3:9));
13963 39191373 int32_t ispitur_75 = getpitfall(x+3,y+(bigHitbox?12:14));
13964 39191373 int32_t ispitbr_75 = getpitfall(x+3,y+(bigHitbox?3:9));
13965 static const int32_t flag_pit_irresistable = (1<<24);
13966
5/5
✓ Branch 0 taken 39142516 times.
✓ Branch 1 taken 3673 times.
✓ Branch 2 taken 666 times.
✓ Branch 3 taken 26542 times.
✓ Branch 4 taken 17976 times.
39191373 switch((ispitul?1:0) + (ispitur?1:0) + (ispitbl?1:0) + (ispitbr?1:0))
13967 {
13968 3673 case 4: return -2; //Fully over pit; fall in
13969 case 3:
13970 {
13971
6/6
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 218 times.
✓ Branch 3 taken 118 times.
✓ Branch 4 taken 202 times.
✓ Branch 5 taken 16 times.
666 if(ispitul && ispitur && ispitbl) //UL_3
13972 {
13973
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(ispitul_50)
13974 {
13975
3/6
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
16 if (!ispitul_75 && (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))) return -1;
13976 3 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
13977 }
13978 }
13979
5/6
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 202 times.
✓ Branch 3 taken 118 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 202 times.
650 else if(ispitul && ispitur && ispitbr) //UR_3
13980 {
13981
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 172 times.
202 if(ispitur_50)
13982 {
13983
5/6
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
30 if (!ispitur_75 && (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION))) return -1;
13984 18 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
13985 }
13986 172 }
13987
4/6
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 330 times.
✓ Branch 2 taken 118 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 118 times.
448 else if(ispitul && ispitbl && ispitbr) //BL_3
13988 {
13989
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 108 times.
118 if(ispitbl_50)
13990 {
13991
4/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
10 if (!ispitbl_75 && (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))) return -1;
13992 10 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
13993 }
13994 108 }
13995
3/6
✓ Branch 0 taken 330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 330 times.
330 else if(ispitbl && ispitur && ispitbr) //BR_3
13996 {
13997
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 328 times.
330 if(ispitbr_50)
13998 {
13999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if (!ispitbr_75 && (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION))) return -1;
14000 2 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14001 }
14002 328 }
14003 608 break;
14004 }
14005 case 2:
14006 {
14007
4/4
✓ Branch 0 taken 13871 times.
✓ Branch 1 taken 12671 times.
✓ Branch 2 taken 11998 times.
✓ Branch 3 taken 1873 times.
26542 if(ispitul && ispitur) //Up
14008 {
14009
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 1786 times.
1873 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
14010 {
14011
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
87 if(ispitul_75 && ispitur_75) //Straight up
14012 {
14013 return up | flag_pit_irresistable | (ispitul << 8);
14014 }
14015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 87 times.
87 else if(ispitul_75)
14016 {
14017 return (can_diag ? l_up : left) | flag_pit_irresistable | (ispitul << 8);
14018 }
14019
1/2
✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
87 else if(ispitur_75)
14020 {
14021 return (can_diag ? r_up : right) | flag_pit_irresistable | (ispitur << 8);
14022 }
14023 87 else return -1;
14024 }
14025 else
14026 {
14027
3/4
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 1631 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 155 times.
1786 if(ispitul_50 && ispitur_50) //Straight up
14028 {
14029
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 100 times.
155 return up | ((ispitul_75 || ispitur_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
14030 }
14031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1631 times.
1631 else if(ispitul_50)
14032 {
14033 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && !ispitul_75) return -1;
14034 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
14035 }
14036
1/2
✓ Branch 0 taken 1631 times.
✗ Branch 1 not taken.
1631 else if(ispitur_50)
14037 {
14038 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !ispitur_75) return -1;
14039 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
14040 }
14041 }
14042 1631 }
14043
4/4
✓ Branch 0 taken 14204 times.
✓ Branch 1 taken 10465 times.
✓ Branch 2 taken 11986 times.
✓ Branch 3 taken 2218 times.
24669 else if(ispitbl && ispitbr) //Down
14044 {
14045
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 2162 times.
2218 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION))
14046 {
14047
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
56 if(ispitbl_75 && ispitbr_75) //Straight down
14048 {
14049 3 return down | flag_pit_irresistable | (ispitbl << 8);
14050 }
14051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 else if(ispitbl_75)
14052 {
14053 return (can_diag ? l_down : left) | flag_pit_irresistable | (ispitbl << 8);
14054 }
14055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 else if(ispitbr_75)
14056 {
14057 return (can_diag ? r_down : right) | flag_pit_irresistable | (ispitbr << 8);
14058 }
14059 53 else return -1;
14060 }
14061 else
14062 {
14063
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 2127 times.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
2162 if(ispitbl_50 && ispitbr_50) //Straight down
14064 {
14065
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 27 times.
35 return down | ((ispitbl_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitbl << 8);
14066 }
14067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
2127 else if(ispitbl_50)
14068 {
14069 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && !ispitbl_75) return -1;
14070 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14071 }
14072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127 times.
2127 else if(ispitbr_50)
14073 {
14074 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !ispitbr_75) return -1;
14075 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14076 }
14077 }
14078 2127 }
14079
3/4
✓ Branch 0 taken 11986 times.
✓ Branch 1 taken 10465 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11986 times.
22451 else if(ispitbl && ispitul) //Left
14080 {
14081
2/2
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 11359 times.
11986 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))
14082 {
14083
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 627 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
627 if(ispitul_75 && ispitbl_75) //Straight left
14084 {
14085 return left | flag_pit_irresistable | (ispitul << 8);
14086 }
14087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 627 times.
627 else if(ispitul_75)
14088 {
14089 return (can_diag ? l_up : up) | flag_pit_irresistable | (ispitul << 8);
14090 }
14091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 627 times.
627 else if(ispitbl_75)
14092 {
14093 return (can_diag ? l_down : down) | flag_pit_irresistable | (ispitbl << 8);
14094 }
14095 627 else return -1;
14096 }
14097 else
14098 {
14099
3/4
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 11044 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 315 times.
11359 if(ispitul_50 && ispitbl_50) //Straight left
14100 {
14101
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 231 times.
315 return left | ((ispitul_75 || ispitbl_75) ? flag_pit_irresistable : 0) | (ispitul << 8);
14102 }
14103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11044 times.
11044 else if(ispitul_50)
14104 {
14105 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && !ispitul_75) return -1;
14106 return (can_diag ? l_up : up) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
14107 }
14108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11044 times.
11044 else if(ispitbl_50)
14109 {
14110 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && !ispitbl_75) return -1;
14111 return (can_diag ? l_down : down) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14112 }
14113 }
14114 11044 }
14115
3/4
✓ Branch 0 taken 10465 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 10453 times.
10465 else if(ispitbr && ispitur) //Right
14116 {
14117
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 9875 times.
10453 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION))
14118 {
14119
3/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 565 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
578 if(ispitur_75 && ispitbr_75) //Straight right
14120 {
14121 13 return right | flag_pit_irresistable | (ispitur << 8);
14122 }
14123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 else if(ispitur_75)
14124 {
14125 return (can_diag ? r_up : up) | flag_pit_irresistable | (ispitur << 8);
14126 }
14127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 565 times.
565 else if(ispitbr_75)
14128 {
14129 return (can_diag ? r_down : down) | flag_pit_irresistable | (ispitbr << 8);
14130 }
14131 565 else return -1;
14132 }
14133 else
14134 {
14135
3/4
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 9536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 339 times.
9875 if(ispitur_50 && ispitbr_50) //Straight right
14136 {
14137
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 117 times.
339 return right | ((ispitur_75 || ispitbr_75) ? flag_pit_irresistable : 0) | (ispitur << 8);
14138 }
14139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9536 times.
9536 else if(ispitur_50)
14140 {
14141 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && !ispitur_75) return -1;
14142 return (can_diag ? r_up : up) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
14143 }
14144
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9536 times.
9536 else if(ispitbr_50)
14145 {
14146 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && !ispitbr_75) return -1;
14147 return (can_diag ? r_down : down) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14148 }
14149 }
14150 9536 }
14151 24350 break;
14152 }
14153 case 1:
14154 {
14155
4/4
✓ Branch 0 taken 5636 times.
✓ Branch 1 taken 12340 times.
✓ Branch 2 taken 5633 times.
✓ Branch 3 taken 3 times.
17976 if(ispitul && ispitul_50) //UL_1
14156 {
14157
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if (!ispitul_75 && (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))) return -1;
14158 3 return (can_diag ? l_up : left) | (ispitul_75 ? flag_pit_irresistable : 0) | (ispitul << 8);
14159 }
14160
4/4
✓ Branch 0 taken 4168 times.
✓ Branch 1 taken 13805 times.
✓ Branch 2 taken 4116 times.
✓ Branch 3 taken 52 times.
17973 if(ispitur && ispitur_50) //UR_1
14161 {
14162
5/6
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 13 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 9 times.
52 if (!ispitur_75 && (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION))) return -1;
14163 9 return (can_diag ? r_up : right) | (ispitur_75 ? flag_pit_irresistable : 0) | (ispitur << 8);
14164 }
14165
4/4
✓ Branch 0 taken 3253 times.
✓ Branch 1 taken 14668 times.
✓ Branch 2 taken 3251 times.
✓ Branch 3 taken 2 times.
17921 if(ispitbl && ispitbl_50) //BL_1
14166 {
14167
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 if (!ispitbl_75 && (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))) return -1;
14168 return (can_diag ? l_down : left) | (ispitbl_75 ? flag_pit_irresistable : 0) | (ispitbl << 8);
14169 }
14170
4/4
✓ Branch 0 taken 4919 times.
✓ Branch 1 taken 13000 times.
✓ Branch 2 taken 4877 times.
✓ Branch 3 taken 42 times.
17919 if(ispitbr && ispitbr_50) //BR_1
14171 {
14172
5/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 4 times.
42 if (!ispitbr_75 && (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION))) return -1;
14173 4 return (can_diag ? r_down : right) | (ispitbr_75 ? flag_pit_irresistable : 0) | (ispitbr << 8);
14174 }
14175 17877 break;
14176 }
14177 }
14178 39185351 }
14179 40388285 return -1;
14180 40394307 }
14181
14182 11975059 bool HeroClass::pitslide() //Runs pitslide movement; returns true if pit is irresistable
14183 {
14184 11975059 pitfall();
14185
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 11975042 times.
11975059 if(fallclk) return true;
14186 11975042 int32_t val = check_pitslide();
14187 //Val should not be -2 here; if -2 would have been returned, the 'return true' above should have triggered!
14188
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 11974840 times.
11975042 if(val == -1)
14189 {
14190 11974840 pit_pulldir = -1;
14191 11974840 pit_pullclk = 0;
14192 11974840 return false;
14193 }
14194 202 int32_t dir = val&0xFF;
14195 202 int32_t cmbid = (val&0xFFFF00)>>8;
14196 202 int32_t sensitivity = combobuf[cmbid].attribytes[2];
14197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202 times.
202 if(combobuf[cmbid].usrflags&cflag5) //No pull at all
14198 {
14199 pit_pulldir = -1;
14200 pit_pullclk = 0;
14201 return false;
14202 }
14203
4/6
✓ Branch 0 taken 202 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 200 times.
✓ Branch 5 taken 2 times.
202 if(dir > -1 && !(hoverflags & HOV_PITFALL_OUT) && try_hover()) //Engage hovers
14204 {
14205 2 pit_pulldir = -1;
14206 2 pit_pullclk = 0;
14207 2 return false;
14208 }
14209 200 pit_pulldir = dir;
14210 200 int32_t step = 1;
14211
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 10 times.
200 if(sensitivity == 0)
14212 {
14213 10 step = 2;
14214 10 sensitivity = 1;
14215 10 }
14216
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 152 times.
200 if(pit_pullclk++ % sensitivity) //No pull this frame
14217 48 return (val&0x100);
14218
4/4
✓ Branch 0 taken 150 times.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 152 times.
312 for(; step > 0 && !fallclk; --step)
14219 {
14220
3/3
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 68 times.
✓ Branch 2 taken 40 times.
160 switch(dir)
14221 {
14222 case l_up: case l_down: case left:
14223 52 --x; break;
14224 case r_up: case r_down: case right:
14225 68 ++x; break;
14226 }
14227
3/3
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 112 times.
160 switch(dir)
14228 {
14229 case l_up: case r_up: case up:
14230 37 --y; break;
14231 case l_down: case r_down: case down:
14232 11 ++y; break;
14233 }
14234 160 pitfall();
14235 160 }
14236
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 34 times.
152 return fallclk || (val&0x100);
14237 11975059 }
14238
14239 11978789 void HeroClass::pitfall()
14240 {
14241
2/2
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 11975219 times.
11978789 if(fallclk)
14242 {
14243 3570 drop_liftwpn();
14244
3/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 3519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
3570 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x));
14245 //Handle falling
14246
2/2
✓ Branch 0 taken 3519 times.
✓ Branch 1 taken 51 times.
3570 if(!--fallclk)
14247 {
14248 51 optional<combined_handle_t> comb_handle;
14249
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
51 if((comb_handle = get_pitfall_handle(x+8, y+(bigHitbox?8:12))) && comb_handle->data() == fallCombo) /*nil*/;
14250 else if((comb_handle = get_pitfall_handle(x+8, y+(bigHitbox?0:8))) && comb_handle->data() == fallCombo) /*nil*/;
14251 else if((comb_handle = get_pitfall_handle(x+15, y+(bigHitbox?0:8))) && comb_handle->data() == fallCombo) /*nil*/;
14252 else if((comb_handle = get_pitfall_handle(x, y+15)) && comb_handle->data() == fallCombo) /*nil*/;
14253 else if((comb_handle = get_pitfall_handle(x+15, y+15)) && comb_handle->data() == fallCombo) /*nil*/;
14254 else comb_handle = nullopt; // nothing found, no `CType Causes->`
14255
14256 51 std::vector<int32_t> &ev = FFCore.eventData;
14257 51 ev.clear();
14258 51 ev.push_back(fallCombo*10000);
14259
14260 51 throwGenScriptEvent(GENSCR_EVENT_PLAYER_FALL);
14261
14262 51 fallCombo = ev[0]/10000;
14263
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51 times.
51 if(fallCombo < 0 || fallCombo >= MAXCOMBOS)
14264 fallCombo = 0;
14265
14266 51 int32_t dmg = game->get_hp_per_heart()/4;
14267 51 bool dmg_perc = false;
14268 51 bool warp = false;
14269
14270 51 action=none; FFCore.setHeroAction(none);
14271
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 newcombo* cmb = fallCombo ? &combobuf[fallCombo] : NULL;
14272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(cmb)
14273 {
14274 51 dmg = cmb->attributes[0]/10000L;
14275 51 dmg_perc = cmb->usrflags&cflag3;
14276 51 warp = cmb->usrflags&cflag1;
14277 51 }
14278
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
51 if(cheat_superman && dmg > 0)
14279 dmg = 0;
14280
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 38 times.
51 if(dmg) //Damage
14281 {
14282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(dmg > 0)
14283 {
14284 38 hclk=48; //IFrames only if damaged, not if healed
14285 38 check_on_hit();
14286 38 }
14287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 game->set_life(vbound(int32_t(dmg_perc ? game->get_life() - ((vbound(dmg,-100,100)/100.0)*game->get_maxlife()) : (game->get_life()-int64_t(dmg))),0,game->get_maxlife()));
14288 38 }
14289
14290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(comb_handle)
14291 51 do_trigger_ctype_causes(*comb_handle);
14292
14293
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 47 times.
51 if(warp) //Warp
14294 {
14295 4 sdir = dir;
14296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(cmb->usrflags&cflag2) //Direct Warp
14297 {
14298 4 setpit();
14299 4 }
14300 4 dowarp(hero_scr, 0, vbound(cmb->attribytes[1],0,3), 0);
14301 4 }
14302 else //Reset to screen entry
14303 {
14304 47 go_respawn_point();
14305 }
14306 51 }
14307 3570 }
14308
2/2
✓ Branch 0 taken 437762 times.
✓ Branch 1 taken 11537457 times.
11975219 else if(can_pitfall())
14309 {
14310 11537457 bool ispitul = ispitfall(x,y+(bigHitbox?0:8));
14311 11537457 bool ispitbl = ispitfall(x,y+15);
14312 11537457 bool ispitur = ispitfall(x+15,y+(bigHitbox?0:8));
14313 11537457 bool ispitbr = ispitfall(x+15,y+15);
14314 11537457 int32_t pitctr = getpitfall(x+8,y+(bigHitbox?8:12));
14315
9/10
✓ Branch 0 taken 4581 times.
✓ Branch 1 taken 11532876 times.
✓ Branch 2 taken 2849 times.
✓ Branch 3 taken 1732 times.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 2795 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 51 times.
11537457 if(ispitul && ispitbl && ispitur && ispitbr && pitctr)
14316 {
14317
2/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
51 if(!(hoverflags & HOV_PITFALL_OUT) && try_hover()) return;
14318
3/4
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 41 times.
51 if(!bigHitbox && !ispitfall(x,y)) y = (y.getInt() + 8 - (y.getInt() % 8)); //Make the falling sprite fully over the pit
14319 51 fallclk = PITFALL_FALL_FRAMES;
14320 51 fallCombo = pitctr;
14321 51 action=falling; FFCore.setHeroAction(falling);
14322 51 spins = 0;
14323 51 charging = 0;
14324 51 drop_liftwpn();
14325 51 }
14326 11537457 }
14327 11978789 }
14328
14329 160 void HeroClass::handle_slide(newcombo const& icecmb, zfix& dx, zfix& dy)
14330 {
14331
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 bool is_inair = z || fakez;
14332 160 zfix odx = dx, ody = dy;
14333
3/4
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 155 times.
✗ Branch 3 not taken.
160 if(sliding == 2 && !is_inair) //landed from air-sliding
14334 {
14335 if((ice_vx+odx).sign() != ice_vx.sign())
14336 ice_vx = 0;
14337 if((ice_vy+ody).sign() != ice_vy.sign())
14338 ice_vy = 0;
14339 sliding = 1;
14340 }
14341
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(!sliding) //just hit the ice
14342 {
14343 if(is_inair)
14344 return;
14345 sliding = 1;
14346 zfix start_perc = icecmb.attribytes[0] / 100_zf;
14347 ice_vx = dx * start_perc;
14348 ice_vy = dy * start_perc;
14349 ice_entry_count = ice_entry_mcount = icecmb.attribytes[1];
14350 }
14351 else //not the first frame sliding
14352 {
14353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(is_inair)
14354 160 sliding = 2;
14355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 zfix accel = zslongToFix(zc_max(1,icecmb.attributes[0]));
14356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 zfix decel = zslongToFix(zc_max(1,icecmb.attributes[1]));
14357
14358
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(ice_entry_count)
14359 {
14360 if(--ice_entry_count)
14361 {
14362 zfix perc = zfix(ice_entry_count)/ice_entry_mcount;
14363 perc *= perc; //square the portion, for a better transition
14364 zfix normal_rate = zfix(steprate)/100/2;
14365 decel = (perc*normal_rate)+((1-perc)*decel);
14366 }
14367 }
14368 //!TODO Traction Boots can be added here, with a multiplier on accel/decel
14369 //Accelerate in the pushed direction
14370
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(is_inair)
14371 {
14372 static const int air_accel = 100;
14373 160 accel = abs(odx)/air_accel;
14374
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(accel)
14375 {
14376 if(odx < 0)
14377 {
14378 if(ice_vx - accel < odx)
14379 {
14380 if(ice_vx > odx)
14381 ice_vx = odx;
14382 else odx = 0; //allow decel
14383 }
14384 else ice_vx -= accel;
14385 }
14386 else //if(odx > 0)
14387 {
14388 if(ice_vx + accel > odx)
14389 {
14390 if(ice_vx < odx)
14391 ice_vx = odx;
14392 else odx = 0; //allow decel
14393 }
14394 else ice_vx += accel;
14395 }
14396 }
14397 160 accel = abs(ody)/air_accel;
14398
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(accel)
14399 {
14400 if(ody < 0)
14401 {
14402 if(ice_vy - accel < ody)
14403 {
14404 if(ice_vy > ody)
14405 ice_vy = ody;
14406 else ody = 0; //allow decel
14407 }
14408 else ice_vy -= accel;
14409 }
14410 else //if(ody > 0)
14411 {
14412 if(ice_vy + accel > ody)
14413 {
14414 if(ice_vy < ody)
14415 ice_vy = ody;
14416 else ody = 0; //allow decel
14417 }
14418 else ice_vy += accel;
14419 }
14420 }
14421 160 }
14422 else if(accel)
14423 {
14424 if(odx > 0)
14425 ice_vx += accel;
14426 else if(odx < 0)
14427 ice_vx -= accel;
14428 if(ody > 0)
14429 ice_vy += accel;
14430 else if(ody < 0)
14431 ice_vy -= accel;
14432 }
14433 //Decelerate in non-pushed direction
14434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(is_inair)
14435 160 decel = zinit.air_drag;
14436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(decel)
14437 {
14438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(ice_vx)
14439 {
14440
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if(!odx && abs(ice_vx) < decel)
14441 ice_vx = 0;
14442
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 64 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
160 else if(ice_vx > 0 && odx <= 0)
14443 96 ice_vx -= decel;
14444
2/4
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
64 else if(ice_vx < 0 && odx >= 0)
14445 64 ice_vx += decel;
14446 160 }
14447
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(ice_vy)
14448 {
14449 if(!ody && abs(ice_vy) < decel)
14450 ice_vy = 0;
14451 else if(ice_vy > 0 && ody <= 0)
14452 ice_vy -= decel;
14453 else if(ice_vy < 0 && ody >= 0)
14454 ice_vy += decel;
14455 }
14456 160 }
14457 }
14458
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 zfix cap = zslongToFix(zc_max(1,abs(icecmb.attributes[2])));
14459 160 dx = ice_vx = vbound(ice_vx, -cap, cap);
14460 160 dy = ice_vy = vbound(ice_vy, -cap, cap);
14461
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
160 if(!dx && !dy)
14462 ice_entry_count = 0;
14463 160 }
14464 257218 void HeroClass::mod_steps(std::vector<zfix*>& v)
14465 {
14466
3/4
✓ Branch 0 taken 256544 times.
✓ Branch 1 taken 674 times.
✓ Branch 2 taken 256544 times.
✗ Branch 3 not taken.
257218 bool can_combo = ((z==0 && fakez==0) || hero_scr->flags2&fAIRCOMBOS);
14467
4/6
✓ Branch 0 taken 21068 times.
✓ Branch 1 taken 236150 times.
✓ Branch 2 taken 21068 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21068 times.
✗ Branch 5 not taken.
493368 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1) && can_combo) ||
14468
5/6
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 235389 times.
✓ Branch 2 taken 652 times.
✓ Branch 3 taken 109 times.
✓ Branch 4 taken 761 times.
✗ Branch 5 not taken.
236150 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1,-1));
14469 //!DIMITODO: add QR for slow combos under hero
14470
4/4
✓ Branch 0 taken 236150 times.
✓ Branch 1 taken 21068 times.
✓ Branch 2 taken 21068 times.
✓ Branch 3 taken 42136 times.
299354 if(slowcombo) for (int32_t i = 1; i <= 2; ++i)
14471 {
14472
2/2
✓ Branch 0 taken 956 times.
✓ Branch 1 taken 41180 times.
42136 if (get_scr_layer_valid(current_screen, i))
14473 {
14474
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41180 times.
41180 if (get_qr(qr_OLD_BRIDGE_COMBOS))
14475 {
14476 if (combobuf[MAPCOMBO2(i-1, x+7, y+8)].type == cBRIDGE && !_walkflag_layer(x+7, y+8, i))
14477 {
14478 slowcombo = false;
14479 break;
14480 }
14481 }
14482 else
14483 {
14484
2/4
✓ Branch 0 taken 41180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41180 times.
✗ Branch 3 not taken.
41180 if (combobuf[MAPCOMBO2(i-1, x+7, y+8)].type == cBRIDGE && _effectflag_layer(x+7, y+8, i))
14485 {
14486 slowcombo = false;
14487 break;
14488 }
14489 }
14490 41180 }
14491 63204 }
14492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 257218 times.
257218 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & item_flag10);
14493 257218 bool is_swimming = (action == swimming);
14494 257218 int32_t shieldid = getCurrentActiveShield();
14495
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 257218 times.
257218 if(shieldid > -1)
14496 {
14497 itemdata const& shield = itemsbuf[shieldid];
14498 if(shield.flags & item_flag10) //Change Speed flag
14499 {
14500 zfix perc = shield.misc7;
14501 perc /= 100;
14502 if(perc < 0)
14503 perc = (perc*-1)+1;
14504 zfix add(shield.misc8);
14505 add /= 100;
14506 for(zfix* stp : v)
14507 {
14508 zfix& pix = *stp;
14509 pix = (pix * perc) + add;
14510 }
14511 }
14512 }
14513
14514
2/2
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 256544 times.
257218 if (can_combo)
14515 {
14516 256544 rpos_t slow_rpos = COMBOPOS_REGION_B(x+7, y+8);
14517
2/2
✓ Branch 0 taken 255966 times.
✓ Branch 1 taken 1794863 times.
2050829 for (int q = 6; q >= 0; --q)
14518 {
14519
1/2
✓ Branch 0 taken 1794863 times.
✗ Branch 1 not taken.
1794863 if (slow_rpos == rpos_t::None) break;
14520 1794863 auto& cmb = get_rpos_handle(slow_rpos, q).combo();
14521
14522
3/6
✓ Branch 0 taken 1794774 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1794774 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1794863 if (cmb.speed_mult != 1 || cmb.speed_div || cmb.speed_add)
14523 {
14524
2/2
✓ Branch 0 taken 8974315 times.
✓ Branch 1 taken 1794863 times.
10769178 for (zfix* stp : v)
14525 {
14526 8974315 zfix& pix = *stp;
14527 8974315 pix *= cmb.speed_mult;
14528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8974315 times.
8974315 if(cmb.speed_div)
14529 8974315 pix /= cmb.speed_div;
14530 8974315 pix += cmb.speed_add;
14531 }
14532 1794863 }
14533
14534
4/4
✓ Branch 0 taken 1538897 times.
✓ Branch 1 taken 255966 times.
✓ Branch 2 taken 1538319 times.
✓ Branch 3 taken 578 times.
1794863 if (q > 0 && cmb.type == cBRIDGE)
14535 {
14536
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 578 times.
✓ Branch 2 taken 578 times.
✗ Branch 3 not taken.
578 if(get_qr(qr_OLD_BRIDGE_COMBOS)
14537 ? !_walkflag_layer(x+7,y+8,q-1)
14538 578 : _effectflag_layer(x+7,y+8,q-1))
14539 {
14540 578 break; //Bridge blocks speed change from below it
14541 }
14542 }
14543 1794285 }
14544 256544 }
14545
14546 257218 zfix mult = 1, div = 1;
14547
2/2
✓ Branch 0 taken 6290 times.
✓ Branch 1 taken 250928 times.
257218 if(is_swimming)
14548 {
14549 6290 mult = game->swim_mult;
14550 6290 div = game->swim_div;
14551 6290 }
14552
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 250928 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
250928 else if(slowcharging && slowcombo) //1/2 speed
14553 {
14554 div = 2;
14555 }
14556
3/4
✓ Branch 0 taken 250928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21068 times.
✓ Branch 3 taken 229860 times.
250928 else if(slowcharging || slowcombo) //2/3 speed
14557 {
14558 21068 mult = 2;
14559 21068 div = 3;
14560 21068 }
14561
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 if(!div) div = 1;
14562
3/4
✓ Branch 0 taken 229860 times.
✓ Branch 1 taken 27358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229860 times.
257218 if(mult != 1 || div != 1)
14563 {
14564
2/2
✓ Branch 0 taken 136790 times.
✓ Branch 1 taken 27358 times.
164148 for(zfix* stp : v)
14565 {
14566 136790 zfix& pix = *stp;
14567 136790 pix = ((pix / div) * mult);
14568 }
14569 27358 }
14570 257218 }
14571
14572 13300109 void HeroClass::moveheroOld()
14573 {
14574
4/4
✓ Branch 0 taken 13292270 times.
✓ Branch 1 taken 7839 times.
✓ Branch 2 taken 7584 times.
✓ Branch 3 taken 13285022 times.
13300109 if(lstunclock || is_conveyor_stunned) return;
14575 13285022 int32_t xoff=x.getInt()&7;
14576 13285022 int32_t yoff=y.getInt()&7;
14577
4/4
✓ Branch 0 taken 13102220 times.
✓ Branch 1 taken 182802 times.
✓ Branch 2 taken 23246 times.
✓ Branch 3 taken 13125466 times.
13285022 if(NO_GRIDLOCK)
14578 {
14579 206048 xoff = 0;
14580 206048 yoff = 0;
14581 206048 }
14582 13315516 int32_t push=pushing;
14583 13315516 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
14584 13315516 pushing=0;
14585 13315516 zfix temp_step(hero_newstep);
14586 13315516 zfix temp_x(x);
14587 13315516 zfix temp_y(y);
14588
14589 13315516 int32_t flippers_id = current_item_id(itype_flippers);
14590 13315516 itemdata const& itm = itemsbuf[flippers_id];
14591 13315516 byte intbtn = byte(itm.misc3&0xFF);
14592 13315516 bool dive_pressed = getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK | INPUT_PEEK);
14593 13315516 bool eatdive = false;
14594
2/2
✓ Branch 0 taken 37580 times.
✓ Branch 1 taken 13277936 times.
13315516 if(diveclk>0)
14595 {
14596
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 37580 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
37580 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
14597 37580 --diveclk;
14598
4/8
✓ Branch 0 taken 9502 times.
✓ Branch 1 taken 28078 times.
✓ Branch 2 taken 9502 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9502 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
37580 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag2 && dive_pressed) //Cancellable Diving -V
14599 {
14600 diveclk = itemsbuf[flippers_id].misc2;
14601 eatdive = true;
14602 }
14603 37580 }
14604
4/4
✓ Branch 0 taken 113504 times.
✓ Branch 1 taken 13164432 times.
✓ Branch 2 taken 113277 times.
✓ Branch 3 taken 227 times.
13277936 else if(action == swimming && dive_pressed)
14605 {
14606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag1);
14607 227 bool screen_diving=(hero_scr->flags5&fTOGGLEDIVING) != 0;
14608
14609
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if(global_diving==screen_diving)
14610 {
14611
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
14612 227 eatdive = true;
14613 227 }
14614 227 }
14615
2/2
✓ Branch 0 taken 13315289 times.
✓ Branch 1 taken 227 times.
13315516 if(eatdive)
14616 227 getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK);
14617
14618
2/2
✓ Branch 0 taken 13202366 times.
✓ Branch 1 taken 113150 times.
13315516 if(action==rafting)
14619 {
14620 113150 do_rafting();
14621
14622
2/2
✓ Branch 0 taken 112795 times.
✓ Branch 1 taken 355 times.
113150 if(action==rafting)
14623 {
14624 112795 return;
14625 }
14626
14627
14628 355 set_respawn_point();
14629 355 trySideviewLadder();
14630 355 }
14631
14632 13202721 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
14633 13202721 int32_t btnwpn = -1;
14634
14635 //&0xFFF removes the "bow & arrows" bitmask
14636 //The Quick Sword is allowed to interrupt attacks.
14637
4/4
✓ Branch 0 taken 13027965 times.
✓ Branch 1 taken 174756 times.
✓ Branch 2 taken 8823055 times.
✓ Branch 3 taken 4204910 times.
13202721 int32_t currentSwordOrWand = (itemsbuf[dowpn].type == itype_wand || itemsbuf[dowpn].type == itype_sword)?dowpn:-1;
14638
8/8
✓ Branch 0 taken 11570436 times.
✓ Branch 1 taken 1632285 times.
✓ Branch 2 taken 11559090 times.
✓ Branch 3 taken 11346 times.
✓ Branch 4 taken 390563 times.
✓ Branch 5 taken 1253068 times.
✓ Branch 6 taken 72183 times.
✓ Branch 7 taken 1571448 times.
13202721 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & item_flag5)))
14639 {
14640
2/2
✓ Branch 0 taken 29031 times.
✓ Branch 1 taken 11602242 times.
11631273 if (getInput(btnB, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
14641 {
14642 29031 btnwpn=getItemFamily(itemsbuf,Bwpn);
14643
2/2
✓ Branch 0 taken 28827 times.
✓ Branch 1 taken 204 times.
29031 dowpn = NEG_OR_MASK(Bwpn,0xFFF);
14644 29031 directWpn = directItemB;
14645 29031 }
14646
2/2
✓ Branch 0 taken 89955 times.
✓ Branch 1 taken 11512287 times.
11602242 else if (getInput(btnA, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
14647 {
14648 89955 btnwpn=getItemFamily(itemsbuf,Awpn);
14649
2/2
✓ Branch 0 taken 87154 times.
✓ Branch 1 taken 2801 times.
89955 dowpn = NEG_OR_MASK(Awpn,0xFFF);
14650 89955 directWpn = directItemA;
14651 89955 }
14652
4/4
✓ Branch 0 taken 197564 times.
✓ Branch 1 taken 11314723 times.
✓ Branch 2 taken 197488 times.
✓ Branch 3 taken 76 times.
11512287 else if (get_qr(qr_SET_XBUTTON_ITEMS) && getInput(btnEx1, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
14653 {
14654 76 btnwpn=getItemFamily(itemsbuf,Xwpn);
14655
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 dowpn = NEG_OR_MASK(Xwpn,0xFFF);
14656 76 directWpn = directItemX;
14657 76 }
14658
4/4
✓ Branch 0 taken 197488 times.
✓ Branch 1 taken 11314723 times.
✓ Branch 2 taken 197363 times.
✓ Branch 3 taken 125 times.
11512211 else if (get_qr(qr_SET_YBUTTON_ITEMS) && getInput(btnEx2, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
14659 {
14660 125 btnwpn=getItemFamily(itemsbuf,Ywpn);
14661
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 dowpn = NEG_OR_MASK(Ywpn,0xFFF);
14662 125 directWpn = directItemY;
14663 125 }
14664
14665
2/2
✓ Branch 0 taken 3944838 times.
✓ Branch 1 taken 7686435 times.
11631273 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
14666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11631273 times.
11631273 if (on_cooldown(itmid))
14667 {
14668 directWpn = olddirectwpn;
14669 btnwpn = -1;
14670 dowpn = -1;
14671 did_scriptb = false;
14672 }
14673 else
14674 {
14675
1/2
✓ Branch 0 taken 11631273 times.
✗ Branch 1 not taken.
11631273 if(directWpn >= MAXITEMS) directWpn = -1;
14676
14677 // The Quick Sword only allows repeated sword or wand swings.
14678
7/8
✓ Branch 0 taken 11559090 times.
✓ Branch 1 taken 72183 times.
✓ Branch 2 taken 72183 times.
✓ Branch 3 taken 11559090 times.
✓ Branch 4 taken 71496 times.
✓ Branch 5 taken 687 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11559777 times.
11631273 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
14679 71496 btnwpn=-1;
14680 }
14681 11631273 }
14682
14683
2/2
✓ Branch 0 taken 4406377 times.
✓ Branch 1 taken 8796344 times.
13202721 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
14684
11/12
✓ Branch 0 taken 12369809 times.
✓ Branch 1 taken 832912 times.
✓ Branch 2 taken 11805694 times.
✓ Branch 3 taken 564115 times.
✓ Branch 4 taken 8210229 times.
✓ Branch 5 taken 3595465 times.
✓ Branch 6 taken 8150799 times.
✓ Branch 7 taken 59430 times.
✓ Branch 8 taken 86530 times.
✓ Branch 9 taken 8064269 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 86530 times.
13202721 if(can_attack() && (swordid > -1 && itemsbuf[swordid].type==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
14685 {
14686
2/2
✓ Branch 0 taken 3645 times.
✓ Branch 1 taken 82885 times.
86530 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
14687
5/6
✓ Branch 0 taken 86528 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 86513 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
86530 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & item_flag6)))
14688 {
14689
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 86513 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
86513 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
14690 {
14691 paymagiccost(attackid,true);
14692 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
14693 }
14694 86513 SetAttack();
14695 86513 attack=wSword;
14696
14697 86513 attackclk=0;
14698
2/2
✓ Branch 0 taken 3628 times.
✓ Branch 1 taken 82885 times.
86513 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x));
14699
14700
7/10
✓ Branch 0 taken 86513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 524 times.
✓ Branch 3 taken 85989 times.
✓ Branch 4 taken 524 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 517 times.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
86513 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
14701 {
14702
1/2
✓ Branch 0 taken 517 times.
✗ Branch 1 not taken.
517 if(!checkmagiccost(dowpn))
14703 {
14704 item_error();
14705 }
14706 else
14707 {
14708 //clear the item script stack for a new script
14709 517 int i = dowpn;
14710 517 FFCore.reset_script_engine_data(ScriptType::Item, i);
14711 517 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
14712 517 did_scripta=true;
14713 }
14714 517 }
14715 86513 }
14716 else
14717 {
14718 17 item_error();
14719 }
14720 86530 }
14721 else
14722 {
14723 13116191 did_scripta=false;
14724 }
14725
14726
6/10
✓ Branch 0 taken 13052590 times.
✓ Branch 1 taken 150131 times.
✓ Branch 2 taken 13052590 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13052590 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13052590 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 13052590 times.
13202721 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
14727 {
14728
3/4
✓ Branch 0 taken 2303034 times.
✓ Branch 1 taken 10749556 times.
✓ Branch 2 taken 2303034 times.
✗ Branch 3 not taken.
13052590 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && canSideviewLadder())
14729 {
14730 setOnSideviewLadder(true);
14731 }
14732
3/4
✓ Branch 0 taken 1995410 times.
✓ Branch 1 taken 11057180 times.
✓ Branch 2 taken 1995410 times.
✗ Branch 3 not taken.
13052590 else if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && canSideviewLadder(true))
14733 {
14734 y+=1;
14735 old_y += 1;
14736 setOnSideviewLadder(true);
14737 }
14738 13052590 }
14739
14740 13202721 int32_t wx=x;
14741 13202721 int32_t wy=y;
14742
3/6
✓ Branch 0 taken 9074082 times.
✓ Branch 1 taken 4128639 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13202721 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
13202721 if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14743 {
14744 if((xoff==0)||diagonalMovement)
14745 {
14746 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = up;
14747 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = down;
14748 }
14749
14750 if((yoff==0)||diagonalMovement)
14751 {
14752 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = left;
14753 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = right;
14754 }
14755 }
14756
14757
5/5
✓ Branch 0 taken 23246 times.
✓ Branch 1 taken 3105435 times.
✓ Branch 2 taken 2662007 times.
✓ Branch 3 taken 3569307 times.
✓ Branch 4 taken 3842726 times.
13202721 switch(dir)
14758 {
14759 case up:
14760 3105435 wy-=16;
14761 3105435 break;
14762
14763 case down:
14764 2662007 wy+=16;
14765 2662007 break;
14766
14767 case left:
14768 3569307 wx-=16;
14769 3569307 break;
14770
14771 case right:
14772 3842726 wx+=16;
14773 3842726 break;
14774 }
14775
14776 13202721 do_lens();
14777
14778 13202721 WalkflagInfo info;
14779
14780 13202721 bool no_jinx = true;
14781
2/2
✓ Branch 0 taken 13201281 times.
✓ Branch 1 taken 1440 times.
13202721 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
14782
2/2
✓ Branch 0 taken 4406377 times.
✓ Branch 1 taken 8796344 times.
13202721 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
14783
2/2
✓ Branch 0 taken 23246 times.
✓ Branch 1 taken 13179475 times.
13202721 if(liftonly)
14784 {
14785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23246 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23246 if(replay_version_check(38) && btnwpn > -1)
14786 {
14787 no_jinx = checkitem_jinx(itmid);
14788 if(no_jinx)
14789 startwpn(itmid);
14790 directWpn = olddirectwpn;
14791 }
14792 23246 }
14793
6/8
✓ Branch 0 taken 12369809 times.
✓ Branch 1 taken 809666 times.
✓ Branch 2 taken 28457 times.
✓ Branch 3 taken 12341352 times.
✓ Branch 4 taken 28457 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 28457 times.
13179475 else if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
14794 {
14795 28457 bool paidmagic = false;
14796
5/8
✓ Branch 0 taken 26672 times.
✓ Branch 1 taken 1785 times.
✓ Branch 2 taken 1785 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1785 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1785 times.
28457 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].type==itype_wand : false) : current_item(itype_wand)))
14797 {
14798
1/2
✓ Branch 0 taken 1785 times.
✗ Branch 1 not taken.
1785 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
14799 1785 no_jinx = checkitem_jinx(attackid);
14800
4/8
✓ Branch 0 taken 1784 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1784 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1784 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1785 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
14801 {
14802
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1784 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1784 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
14803 paymagiccost(attackid,true);
14804 misc_internal_hero_flags |= LF_PAID_WAND_COST;
14805 }
14806 1784 SetAttack();
14807 1784 attack=wWand;
14808 1784 attackclk=0;
14809 1784 }
14810 else
14811 {
14812 1 item_error();
14813 }
14814 1785 }
14815
4/6
✓ Branch 0 taken 2257 times.
✓ Branch 1 taken 24415 times.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2257 times.
28929 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
14816
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2257 times.
2257 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].type==itype_hammer : false) : current_item(itype_hammer)))
14817 {
14818 2257 no_jinx = checkitem_jinx(dowpn);
14819
3/6
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2257 times.
2257 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
14820 {
14821 item_error();
14822 }
14823 else
14824 {
14825 2257 paymagiccost(dowpn);
14826 2257 paidmagic = true;
14827 2257 SetAttack();
14828 2257 attack=wHammer;
14829
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
14830 2257 attackclk=0;
14831 }
14832 2257 }
14833
4/6
✓ Branch 0 taken 1832 times.
✓ Branch 1 taken 22583 times.
✓ Branch 2 taken 1832 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1832 times.
26247 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
14834
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
✓ Branch 2 taken 1832 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1832 times.
1832 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].type==itype_candle : false) : current_item(itype_candle)))
14835 {
14836 //checkbunny handled where magic cost is paid
14837
1/2
✓ Branch 0 taken 1832 times.
✗ Branch 1 not taken.
1832 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
14838 1832 no_jinx = checkitem_jinx(attackid);
14839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
1832 if(no_jinx)
14840 {
14841 1832 SetAttack();
14842 1832 attack=wFire;
14843 1832 attackclk=0;
14844 1832 }
14845 1832 }
14846
4/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 22579 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
22587 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
14847
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
4 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].type==itype_cbyrna : false) : current_item(itype_cbyrna)))
14848 {
14849
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
14850 4 no_jinx = checkitem_jinx(attackid);
14851
3/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
4 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
14852 {
14853
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
14854 paymagiccost(attackid,true);
14855 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
14856 }
14857 4 SetAttack();
14858 4 attack=wCByrna;
14859 4 attackclk=0;
14860 4 }
14861 else
14862 {
14863 item_error();
14864 }
14865 4 }
14866
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22579 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22579 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
14867 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].type==itype_bugnet) : current_item(itype_bugnet)))
14868 {
14869 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
14870 no_jinx = checkitem_jinx(attackid);
14871 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
14872 {
14873 paymagiccost(attackid);
14874 SetAttack();
14875 attack = wBugNet;
14876 attackclk = 0;
14877 sfx(itemsbuf[attackid].usesound);
14878 }
14879 else
14880 {
14881 item_error();
14882 }
14883 }
14884 else
14885 {
14886 22579 no_jinx = checkitem_jinx(itmid);
14887
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 22528 times.
22579 if(no_jinx)
14888 {
14889 22528 paidmagic = startwpn(itmid);
14890
14891
2/2
✓ Branch 0 taken 19443 times.
✓ Branch 1 taken 3085 times.
22528 if(paidmagic)
14892 {
14893
6/10
✓ Branch 0 taken 19423 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 19423 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19423 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 19423 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 19423 times.
19443 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
14894 {
14895 ;
14896 20 }
14897 else
14898 {
14899 19423 SetAttack();
14900 19423 attackclk=0;
14901 19423 attack=none;
14902
14903
2/2
✓ Branch 0 taken 5936 times.
✓ Branch 1 taken 13487 times.
19423 if(btnwpn==itype_brang)
14904 {
14905 13487 attack=wBrang;
14906 13487 }
14907 }
14908 19443 }
14909 else
14910 {
14911 // Weapon not started: directWpn should be reset to prev. value.
14912 3085 directWpn = olddirectwpn;
14913 }
14914 22528 }
14915 }
14916
14917
8/12
✓ Branch 0 taken 28457 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28405 times.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 1276 times.
✓ Branch 5 taken 27129 times.
✓ Branch 6 taken 1210 times.
✓ Branch 7 taken 66 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1210 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28457 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
14918 {
14919
3/4
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1210 times.
1210 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
14920 {
14921 item_error();
14922 }
14923 else
14924 {
14925 // Only charge for magic if item's magic cost wasn't already charged
14926 // for the item's main use.
14927
4/4
✓ Branch 0 taken 1206 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1199 times.
1210 if(!paidmagic && attack!=wWand)
14928 1199 paymagiccost(dowpn);
14929 //clear the item script stack for a new script
14930 1210 int i = dowpn;
14931 1210 FFCore.reset_script_engine_data(ScriptType::Item, i);
14932 1210 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
14933 1210 did_scriptb=true;
14934 }
14935 1210 }
14936
14937
8/12
✓ Branch 0 taken 28405 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 28385 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 28385 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28385 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28385 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 28385 times.
28457 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
14938 {
14939 20 return;
14940 }
14941
2/2
✓ Branch 0 taken 28385 times.
✓ Branch 1 taken 52 times.
28437 if(!no_jinx)
14942 52 did_scriptb = false;
14943 28437 }
14944 else
14945 {
14946 13151018 did_scriptb=false;
14947 }
14948
14949
6/6
✓ Branch 0 taken 11571102 times.
✓ Branch 1 taken 1585107 times.
✓ Branch 2 taken 11447818 times.
✓ Branch 3 taken 123284 times.
✓ Branch 4 taken 23246 times.
✓ Branch 5 taken 11456232 times.
13202701 if(attackclk || action==attacking || action==sideswimattacking)
14950 {
14951
14952
4/8
✓ Branch 0 taken 123284 times.
✓ Branch 1 taken 1608353 times.
✓ Branch 2 taken 123284 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 123284 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1731637 if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
14953 {
14954 if((xoff==0)||diagonalMovement)
14955 {
14956 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = up;
14957 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = down;
14958 }
14959
14960 if((yoff==0)||diagonalMovement)
14961 {
14962 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = left;
14963 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = right;
14964 }
14965 }
14966
14967 1731637 bool attacked = doattack();
14968
14969 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
14970
10/12
✓ Branch 0 taken 1728492 times.
✓ Branch 1 taken 3145 times.
✓ Branch 2 taken 1245326 times.
✓ Branch 3 taken 483166 times.
✓ Branch 4 taken 266041 times.
✓ Branch 5 taken 979285 times.
✓ Branch 6 taken 230392 times.
✓ Branch 7 taken 35649 times.
✓ Branch 8 taken 230392 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 230392 times.
1731637 if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
14971 {
14972
4/4
✓ Branch 0 taken 111335 times.
✓ Branch 1 taken 119057 times.
✓ Branch 2 taken 38493 times.
✓ Branch 3 taken 72842 times.
230392 if((xoff==0)||diagonalMovement)
14973 {
14974
2/2
✓ Branch 0 taken 141117 times.
✓ Branch 1 taken 16433 times.
157550 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = up;
14975
14976
2/2
✓ Branch 0 taken 138033 times.
✓ Branch 1 taken 19517 times.
157550 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = down;
14977 157550 }
14978
14979
4/4
✓ Branch 0 taken 88085 times.
✓ Branch 1 taken 142307 times.
✓ Branch 2 taken 35934 times.
✓ Branch 3 taken 52151 times.
230392 if((yoff==0)||diagonalMovement)
14980 {
14981
2/2
✓ Branch 0 taken 152737 times.
✓ Branch 1 taken 25504 times.
178241 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = left;
14982
14983
2/2
✓ Branch 0 taken 151833 times.
✓ Branch 1 taken 26408 times.
178241 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = right;
14984 178241 }
14985 230392 }
14986
14987
9/10
✓ Branch 0 taken 1615480 times.
✓ Branch 1 taken 116157 times.
✓ Branch 2 taken 1574494 times.
✓ Branch 3 taken 40986 times.
✓ Branch 4 taken 1574059 times.
✓ Branch 5 taken 435 times.
✓ Branch 6 taken 1568260 times.
✓ Branch 7 taken 5799 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1568260 times.
1731637 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
14988 {
14989 1568260 return;
14990 }
14991
2/2
✓ Branch 0 taken 47220 times.
✓ Branch 1 taken 116157 times.
163377 else if(!attacked)
14992 {
14993 // Spin attack - change direction
14994
3/4
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 115492 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 665 times.
116157 if(spins>1 && attack != wHammer)
14995 {
14996 665 spins--;
14997
14998
2/2
✓ Branch 0 taken 620 times.
✓ Branch 1 taken 45 times.
665 if(spins%5==0)
14999 {
15000
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
15001 45 sfx(itemsbuf[id].usesound,pan(x));
15002 45 }
15003 665 attackclk=1;
15004
15005
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✓ Branch 2 taken 166 times.
✓ Branch 3 taken 166 times.
✓ Branch 4 taken 166 times.
665 switch(dir)
15006 {
15007 case up:
15008 167 dir=left;
15009 167 break;
15010
15011 case right:
15012 166 dir=up;
15013 166 break;
15014
15015 case down:
15016 166 dir=right;
15017 166 break;
15018
15019 case left:
15020 166 dir=down;
15021 166 break;
15022 }
15023
15024 665 return;
15025 }
15026 else
15027 {
15028 115492 spins=0;
15029 }
15030
15031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115492 times.
115492 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
15032 115492 else {action=none; FFCore.setHeroAction(none);}
15033 115492 attackclk=0;
15034 115492 charging=0;
15035 115492 }
15036 162712 }
15037
15038
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 11618882 times.
11618944 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
15039 62 return;
15040
15041
2/2
✓ Branch 0 taken 4370362 times.
✓ Branch 1 taken 7248520 times.
11618882 if(action==walking) //still walking
15042 {
15043
9/10
✓ Branch 0 taken 5330346 times.
✓ Branch 1 taken 1918174 times.
✓ Branch 2 taken 3714796 times.
✓ Branch 3 taken 1615550 times.
✓ Branch 4 taken 1957225 times.
✓ Branch 5 taken 1757571 times.
✓ Branch 6 taken 80540 times.
✓ Branch 7 taken 1876685 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 80540 times.
7248520 if (!getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && !autostep)
15044 {
15045
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80540 times.
80540 if(attackclk>0) SetAttack();
15046 80540 else {action = none; FFCore.setHeroAction(none);}
15047 80540 hero_count=-1;
15048 80540 return;
15049 }
15050
15051 7167980 autostep=false;
15052
15053
4/6
✓ Branch 0 taken 4949766 times.
✓ Branch 1 taken 2218214 times.
✓ Branch 2 taken 4949766 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4949766 times.
7167980 if(!(diagonalMovement || NO_GRIDLOCK))
15054 {
15055
2/4
✓ Branch 0 taken 4949766 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4949766 times.
4949766 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
15056 {
15057 if(dir==up&&yoff)
15058 {
15059 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
15060 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
15061 execute(info);
15062
15063 if(!info.isUnwalkable())
15064 {
15065 moveOld2(up);
15066 }
15067 else
15068 {
15069 action=none; FFCore.setHeroAction(none);
15070 }
15071
15072 return;
15073 }
15074
15075 if(dir==down&&yoff)
15076 {
15077 info = walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
15078 info = info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7]));
15079 execute(info);
15080
15081 if(!info.isUnwalkable())
15082 {
15083 moveOld2(down);
15084 }
15085 else
15086 {
15087 action=none; FFCore.setHeroAction(none);
15088 }
15089
15090 return;
15091 }
15092
15093 if(dir==left&&xoff)
15094 {
15095 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) || walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
15096 execute(info);
15097
15098 if(!info.isUnwalkable())
15099 {
15100 moveOld2(left);
15101 }
15102 else
15103 {
15104 action=none; FFCore.setHeroAction(none);
15105 }
15106
15107 return;
15108 }
15109
15110 if(dir==right&&xoff)
15111 {
15112 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
15113 execute(info);
15114
15115 if(!info.isUnwalkable())
15116 {
15117 moveOld2(right);
15118 }
15119 else
15120 {
15121 action=none; FFCore.setHeroAction(none);
15122 }
15123
15124 return;
15125 }
15126 }
15127 else
15128 {
15129
4/4
✓ Branch 0 taken 1152672 times.
✓ Branch 1 taken 3797094 times.
✓ Branch 2 taken 188796 times.
✓ Branch 3 taken 963876 times.
4949766 if(dir==up&&yoff)
15130 {
15131 963876 while(true)
15132 {
15133 963878 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
15134 963878 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
15135 963878 execute(info);
15136
15137
2/2
✓ Branch 0 taken 5173 times.
✓ Branch 1 taken 958705 times.
963878 if(!info.isUnwalkable())
15138 {
15139 958705 hero_newstep = temp_step;
15140 958705 x = temp_x;
15141 958705 y = temp_y;
15142 958705 moveOld2(up);
15143 958705 return;
15144 }
15145 //Could not move, try moving less
15146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
5173 if(temp_y != int32_t(temp_y))
15147 {
15148 temp_y = floor((double)temp_y);
15149 continue;
15150 }
15151
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5171 times.
5173 else if(temp_step > 1)
15152 {
15153
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(temp_step != int32_t(temp_step)) //floor
15154 2 temp_step = floor((double)temp_step);
15155 else --temp_step;
15156 2 continue;
15157 }
15158 else //Can't move less, stop moving
15159 {
15160 5171 action=none; FFCore.setHeroAction(none);
15161 }
15162 5171 return;
15163 }
15164 }
15165
15166
4/4
✓ Branch 0 taken 945269 times.
✓ Branch 1 taken 3040621 times.
✓ Branch 2 taken 156271 times.
✓ Branch 3 taken 788998 times.
3985890 if(dir==down&&yoff)
15167 {
15168 788998 while(true)
15169 {
15170 789052 info = walkflag(temp_x,temp_y+15+temp_step,2,down);
15171 789052 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
15172 789052 execute(info);
15173
15174
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 784597 times.
789052 if(!info.isUnwalkable())
15175 {
15176 784597 hero_newstep = temp_step;
15177 784597 x = temp_x;
15178 784597 y = temp_y;
15179 784597 moveOld2(down);
15180 784597 return;
15181 }
15182 //Could not move, try moving less
15183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4455 times.
4455 if(temp_y != int32_t(temp_y))
15184 {
15185 temp_y = floor((double)temp_y);
15186 continue;
15187 }
15188
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 4401 times.
4455 else if(temp_step > 1)
15189 {
15190
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(temp_step != int32_t(temp_step)) //floor
15191 54 temp_step = floor((double)temp_step);
15192 else --temp_step;
15193 54 continue;
15194 }
15195 else //Can't move less, stop moving
15196 {
15197 4401 action=none; FFCore.setHeroAction(none);
15198 }
15199 4401 return;
15200 }
15201 }
15202
15203
4/4
✓ Branch 0 taken 1387611 times.
✓ Branch 1 taken 1809281 times.
✓ Branch 2 taken 232515 times.
✓ Branch 3 taken 1155096 times.
3196892 if(dir==left&&xoff)
15204 {
15205 1155096 while(true)
15206 {
15207 1155096 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) || walkflag(temp_x-temp_step,temp_y+8,1,left);
15208 1155096 execute(info);
15209
15210
2/2
✓ Branch 0 taken 5165 times.
✓ Branch 1 taken 1149931 times.
1155096 if(!info.isUnwalkable())
15211 {
15212 1149931 hero_newstep = temp_step;
15213 1149931 x = temp_x;
15214 1149931 y = temp_y;
15215 1149931 moveOld2(left);
15216 1149931 return;
15217 }
15218 //Could not move, try moving less
15219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5165 times.
5165 if(temp_x != int32_t(temp_x))
15220 {
15221 temp_x = floor((double)temp_x);
15222 continue;
15223 }
15224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5165 times.
5165 else if(temp_step > 1)
15225 {
15226 if(temp_step != int32_t(temp_step)) //floor
15227 temp_step = floor((double)temp_step);
15228 else --temp_step;
15229 continue;
15230 }
15231 else //Can't move less, stop moving
15232 {
15233 5165 action=none; FFCore.setHeroAction(none);
15234 }
15235 5165 return;
15236 }
15237 }
15238
15239
4/4
✓ Branch 0 taken 1464214 times.
✓ Branch 1 taken 577582 times.
✓ Branch 2 taken 245328 times.
✓ Branch 3 taken 1218886 times.
2041796 if(dir==right&&xoff)
15240 {
15241 1218886 while(true)
15242 {
15243 1218949 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) || walkflag(temp_x+15+temp_step,temp_y+8,1,right);
15244 1218949 execute(info);
15245
15246
2/2
✓ Branch 0 taken 5828 times.
✓ Branch 1 taken 1213121 times.
1218949 if(!info.isUnwalkable())
15247 {
15248 1213121 hero_newstep = temp_step;
15249 1213121 x = temp_x;
15250 1213121 y = temp_y;
15251 1213121 moveOld2(right);
15252 1213121 return;
15253 }
15254 //Could not move, try moving less
15255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5828 times.
5828 if(temp_x != int32_t(temp_x))
15256 {
15257 temp_x = floor((double)temp_x);
15258 continue;
15259 }
15260
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 5765 times.
5828 else if(temp_step > 1)
15261 {
15262
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 if(temp_step != int32_t(temp_step)) //floor
15263 63 temp_step = floor((double)temp_step);
15264 else --temp_step;
15265 63 continue;
15266 }
15267 else //Can't move less, stop moving
15268 {
15269 5765 action=none; FFCore.setHeroAction(none);
15270 }
15271 5765 return;
15272 }
15273 }
15274 }
15275 822910 }
15276
15277 3041124 } // endif (action==walking)
15278
15279
16/24
✓ Branch 0 taken 7276187 times.
✓ Branch 1 taken 135299 times.
✓ Branch 2 taken 7276187 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7276187 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7276187 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7276187 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7276187 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7276187 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 7276187 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 7276187 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 7235201 times.
✓ Branch 19 taken 40986 times.
✓ Branch 20 taken 7234766 times.
✓ Branch 21 taken 435 times.
✓ Branch 22 taken 109495 times.
✓ Branch 23 taken 7125271 times.
7411486 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
15280 {
15281 7125271 action=none; FFCore.setHeroAction(none);
15282 7125271 }
15283
15284
2/2
✓ Branch 0 taken 3632398 times.
✓ Branch 1 taken 3779088 times.
7411486 if(diagonalMovement)
15285 {
15286
5/5
✓ Branch 0 taken 1170413 times.
✓ Branch 1 taken 532104 times.
✓ Branch 2 taken 453865 times.
✓ Branch 3 taken 704485 times.
✓ Branch 4 taken 771531 times.
3632398 switch(holddir)
15287 {
15288 case up:
15289
2/2
✓ Branch 0 taken 515078 times.
✓ Branch 1 taken 17026 times.
532104 if (!getInput(btnUp, INPUT_HERO_ACTION))
15290 {
15291 17026 holddir=-1;
15292 17026 }
15293
15294 532104 break;
15295
15296 case down:
15297
2/2
✓ Branch 0 taken 438723 times.
✓ Branch 1 taken 15142 times.
453865 if (!getInput(btnDown, INPUT_HERO_ACTION))
15298 {
15299 15142 holddir=-1;
15300 15142 }
15301
15302 453865 break;
15303
15304 case left:
15305
2/2
✓ Branch 0 taken 684031 times.
✓ Branch 1 taken 20454 times.
704485 if (!getInput(btnLeft, INPUT_HERO_ACTION))
15306 {
15307 20454 holddir=-1;
15308 20454 }
15309
15310 704485 break;
15311
15312 case right:
15313
2/2
✓ Branch 0 taken 750256 times.
✓ Branch 1 taken 21275 times.
771531 if (!getInput(btnRight, INPUT_HERO_ACTION))
15314 {
15315 21275 holddir=-1;
15316 21275 }
15317
15318 771531 break;
15319
15320 default:
15321 1170413 break;
15322 } //end switch
15323
15324
4/4
✓ Branch 0 taken 3062849 times.
✓ Branch 1 taken 569549 times.
✓ Branch 2 taken 38588 times.
✓ Branch 3 taken 3101437 times.
3632398 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim()) //!DIRECTION SET
15325 {
15326 608137 walkable = false;
15327
6/6
✓ Branch 0 taken 102006 times.
✓ Branch 1 taken 459129 times.
✓ Branch 2 taken 98793 times.
✓ Branch 3 taken 3213 times.
✓ Branch 4 taken 24447 times.
✓ Branch 5 taken 74346 times.
608137 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == up))
15328 {
15329
5/8
✓ Branch 0 taken 3090 times.
✓ Branch 1 taken 74469 times.
✓ Branch 2 taken 3057 times.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3090 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
77559 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
15330 {
15331 }
15332 else
15333 {
15334
5/10
✓ Branch 0 taken 76595 times.
✓ Branch 1 taken 964 times.
✓ Branch 2 taken 76595 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76595 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 76595 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
77559 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
15335 {
15336 76595 dir=up;
15337 76595 }
15338
15339 77559 holddir=up;
15340
15341
4/4
✓ Branch 0 taken 9850 times.
✓ Branch 1 taken 67709 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 9848 times.
77559 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != left)
15342 {
15343 9848 shiftdir=right;
15344
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9848 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
15345
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9848 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9848 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
15346 9848 }
15347
4/4
✓ Branch 0 taken 9049 times.
✓ Branch 1 taken 58662 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9040 times.
67711 else if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != right)
15348 {
15349 9040 shiftdir=left;
15350
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9040 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
9040 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
15351
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9040 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9040 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
15352 9040 }
15353 else
15354 {
15355 58671 shiftdir=-1;
15356 }
15357
15358 //walkable if Ladder can be placed or is already placed vertically
15359
1/18
✗ Branch 0 not taken.
✓ Branch 1 taken 77559 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
77559 if(isSideViewHero() && !toogam && !((can_deploy_ladder() && get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15360 {
15361 walkable=false;
15362 }
15363 else
15364 {
15365
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 77559 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 77555 times.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
77559 if ((get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW) && can_deploy_ladder()) || (ladderx && laddery && ladderdir==up)) justmoved = 2; //Prevent the slope-snap code from running
15366 77559 do
15367 {
15368 89741 zfix ty = y - hero_newstep;
15369 179482 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15370 89741 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15371
15372
4/4
✓ Branch 0 taken 307 times.
✓ Branch 1 taken 89434 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 287 times.
89741 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15373 {
15374 287 info = info || walkflag(x, 0_zf, 2, up);
15375 287 info = info || walkflag(x+15, 0_zf, 1, up);
15376 287 }
15377 89741 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15378
15379 89741 execute(info);
15380
15381
2/2
✓ Branch 0 taken 23217 times.
✓ Branch 1 taken 66524 times.
89741 if(info.isUnwalkable())
15382 {
15383
2/2
✓ Branch 0 taken 1147 times.
✓ Branch 1 taken 22070 times.
23217 if(y != y.getInt())
15384 {
15385 1147 y.doRound();
15386 1147 }
15387
2/2
✓ Branch 0 taken 11035 times.
✓ Branch 1 taken 11035 times.
22070 else if(hero_newstep > 1)
15388 {
15389
1/2
✓ Branch 0 taken 11035 times.
✗ Branch 1 not taken.
11035 if(hero_newstep != int32_t(hero_newstep)) //floor
15390 11035 hero_newstep = floor((double)hero_newstep);
15391 else --hero_newstep;
15392 11035 }
15393 else
15394 11035 break;
15395 12182 }
15396 66524 else walkable = true;
15397
2/2
✓ Branch 0 taken 12182 times.
✓ Branch 1 taken 66524 times.
78706 }
15398 78706 while(!walkable);
15399 }
15400
15401 77559 int32_t s=shiftdir;
15402
15403
5/6
✓ Branch 0 taken 3090 times.
✓ Branch 1 taken 74469 times.
✓ Branch 2 taken 3058 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 3090 times.
✗ Branch 5 not taken.
77559 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM))
15404 {
15405 shiftdir=-1;
15406 }
15407 else
15408 {
15409
2/2
✓ Branch 0 taken 9040 times.
✓ Branch 1 taken 68519 times.
77559 if(s==left)
15410 {
15411 9040 do
15412 {
15413 10486 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
15414
15415 10486 execute(info);
15416
15417
2/2
✓ Branch 0 taken 2765 times.
✓ Branch 1 taken 7721 times.
10486 if(info.isUnwalkable())
15418 {
15419
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 2638 times.
2765 if(x != x.getInt())
15420 {
15421 127 x.doRound();
15422 127 }
15423
2/2
✓ Branch 0 taken 1319 times.
✓ Branch 1 taken 1319 times.
2638 else if(hero_newstep_diag > 1)
15424 {
15425
1/2
✓ Branch 0 taken 1319 times.
✗ Branch 1 not taken.
1319 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15426 1319 hero_newstep_diag.doFloor();
15427 else --hero_newstep_diag;
15428 1319 }
15429 else
15430 1319 shiftdir = -1;
15431 2765 }
15432
2/2
✓ Branch 0 taken 6389 times.
✓ Branch 1 taken 1332 times.
7721 else if(walkable)
15433 {
15434 6389 do
15435 {
15436 6418 info = walkflag(x-hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,left);
15437 6418 execute(info);
15438
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 6372 times.
6418 if(info.isUnwalkable())
15439 {
15440
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 34 times.
46 if(x != x.getInt())
15441 {
15442 12 x.doRound();
15443 12 }
15444
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 17 times.
34 else if(hero_newstep_diag > 1)
15445 {
15446
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15447 17 hero_newstep_diag.doFloor();
15448 else --hero_newstep_diag;
15449 17 }
15450 else
15451 17 shiftdir = -1;
15452 46 }
15453 6372 else break;
15454
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 17 times.
46 }
15455 46 while(shiftdir != -1);
15456 6389 break;
15457 }
15458 1332 else break;
15459
2/2
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 1319 times.
2765 }
15460 2765 while(shiftdir != -1);
15461 9040 }
15462
2/2
✓ Branch 0 taken 58671 times.
✓ Branch 1 taken 9848 times.
68519 else if(s==right)
15463 {
15464 9848 do
15465 {
15466 11460 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
15467
15468 11460 execute(info);
15469
15470
2/2
✓ Branch 0 taken 3070 times.
✓ Branch 1 taken 8390 times.
11460 if(info.isUnwalkable())
15471 {
15472
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 2942 times.
3070 if(x != x.getInt())
15473 {
15474 128 x.doRound();
15475 128 }
15476
2/2
✓ Branch 0 taken 1484 times.
✓ Branch 1 taken 1458 times.
2942 else if(hero_newstep_diag > 1)
15477 {
15478
1/2
✓ Branch 0 taken 1484 times.
✗ Branch 1 not taken.
1484 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15479 1484 hero_newstep_diag.doFloor();
15480 else --hero_newstep_diag;
15481 1484 }
15482 else
15483 1458 shiftdir = -1;
15484 3070 }
15485
2/2
✓ Branch 0 taken 7069 times.
✓ Branch 1 taken 1321 times.
8390 else if(walkable)
15486 {
15487 7069 do
15488 {
15489 7093 info = walkflag(x+15+hero_newstep_diag,(bigHitbox?0:8)+(y-hero_newstep),1,right);
15490 7093 execute(info);
15491
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 7053 times.
7093 if(info.isUnwalkable())
15492 {
15493
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 33 times.
40 if(x != x.getInt())
15494 {
15495 7 x.doRound();
15496 7 }
15497
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 17 times.
33 else if(hero_newstep_diag > 1)
15498 {
15499
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15500 17 hero_newstep_diag.doFloor();
15501 else --hero_newstep_diag;
15502 17 }
15503 else
15504 16 shiftdir = -1;
15505 40 }
15506 7053 else break;
15507
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 16 times.
40 }
15508 40 while(shiftdir != -1);
15509 7069 break;
15510 }
15511 1321 else break;
15512
2/2
✓ Branch 0 taken 1612 times.
✓ Branch 1 taken 1458 times.
3070 }
15513 3070 while(shiftdir != -1);
15514 9848 }
15515 }
15516
15517 77559 moveOld2(up);
15518 77559 shiftdir=s;
15519
15520
2/2
✓ Branch 0 taken 66524 times.
✓ Branch 1 taken 11035 times.
77559 if(!walkable)
15521 {
15522
2/2
✓ Branch 0 taken 3031 times.
✓ Branch 1 taken 8004 times.
11035 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15523 {
15524 8004 x = x.getInt();
15525 8004 y = y.getInt();
15526
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8004 times.
✓ Branch 2 taken 8004 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6226 times.
✓ Branch 5 taken 1778 times.
✓ Branch 6 taken 532 times.
✓ Branch 7 taken 7472 times.
9782 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
15527
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1778 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1778 times.
✓ Branch 4 taken 1115 times.
✓ Branch 5 taken 663 times.
1778 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
15528
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 663 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 663 times.
663 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
15529 {
15530
7/12
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 520 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 520 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 520 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 520 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 532 times.
532 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
15531 532 sprite::move((zfix)-1,(zfix)0);
15532 532 }
15533 else
15534 {
15535
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7472 times.
✓ Branch 4 taken 1246 times.
✓ Branch 5 taken 6226 times.
✓ Branch 6 taken 589 times.
✓ Branch 7 taken 6883 times.
13698 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
15536
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6226 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6226 times.
✓ Branch 4 taken 5637 times.
✓ Branch 5 taken 589 times.
6226 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
15537
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
589 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
15538 {
15539
7/12
✓ Branch 0 taken 582 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 582 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 582 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 582 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 582 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 589 times.
589 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
15540 589 sprite::move((zfix)1,(zfix)0);
15541 589 }
15542 else
15543 {
15544 6883 pushing=push+1;
15545 }
15546 }
15547 8004 }
15548 else
15549 {
15550 3031 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15551 }
15552 11035 }
15553
15554 77559 return;
15555 }
15556 }
15557
15558
6/6
✓ Branch 0 taken 98716 times.
✓ Branch 1 taken 384860 times.
✓ Branch 2 taken 95582 times.
✓ Branch 3 taken 3134 times.
✓ Branch 4 taken 73293 times.
✓ Branch 5 taken 22289 times.
483576 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == down))
15559 {
15560
4/8
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 73740 times.
✓ Branch 2 taken 2687 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2687 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
76427 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
15561 {
15562 }
15563 else
15564 {
15565
5/10
✓ Branch 0 taken 76223 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 76223 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76223 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 76223 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
76427 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
15566 {
15567 76223 dir=down;
15568 76223 }
15569
15570 76427 holddir=down;
15571
15572
4/4
✓ Branch 0 taken 10699 times.
✓ Branch 1 taken 65728 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 10691 times.
76427 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != left)
15573 {
15574 10691 shiftdir=right;
15575
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 10691 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10691 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
15576
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 10691 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
10691 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
15577 10691 }
15578
4/4
✓ Branch 0 taken 11515 times.
✓ Branch 1 taken 54221 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 11503 times.
65736 else if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != right)
15579 {
15580 11503 shiftdir=left;
15581
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 11503 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
11503 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
15582
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11503 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11503 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
15583 11503 }
15584 else
15585 {
15586 54233 shiftdir=-1;
15587 }
15588
15589 //bool walkable;
15590
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 76427 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
76427 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
15591 {
15592 walkable=false;
15593 }
15594 else
15595 {
15596 76427 do
15597 {
15598 85872 info = walkflag(x,15+(y+hero_newstep),2,down);
15599
15600
2/2
✓ Branch 0 taken 52594 times.
✓ Branch 1 taken 33278 times.
85872 if(x.getFloor() & 7)
15601 52594 info = info || walkflag(x+15,15+(y+hero_newstep),1,down);
15602 else
15603 33278 info = info || walkflagMBlock(x+15, 15+(y+hero_newstep));
15604
15605 85872 execute(info);
15606
15607
2/2
✓ Branch 0 taken 17827 times.
✓ Branch 1 taken 68045 times.
85872 if(info.isUnwalkable())
15608 {
15609
2/2
✓ Branch 0 taken 825 times.
✓ Branch 1 taken 17002 times.
17827 if(y != y.getInt())
15610 {
15611 825 y.doRound();
15612 825 }
15613
2/2
✓ Branch 0 taken 8620 times.
✓ Branch 1 taken 8382 times.
17002 else if(hero_newstep > 1)
15614 {
15615
1/2
✓ Branch 0 taken 8620 times.
✗ Branch 1 not taken.
8620 if(hero_newstep != int32_t(hero_newstep)) //floor
15616 8620 hero_newstep = floor((double)hero_newstep);
15617 else --hero_newstep;
15618 8620 }
15619 else
15620 8382 break;
15621 9445 }
15622 68045 else walkable = true;
15623
2/2
✓ Branch 0 taken 9445 times.
✓ Branch 1 taken 68045 times.
77490 }
15624 77490 while(!walkable);
15625 }
15626
15627 76427 int32_t s=shiftdir;
15628
15629
5/6
✓ Branch 0 taken 2687 times.
✓ Branch 1 taken 73740 times.
✓ Branch 2 taken 2685 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2687 times.
✗ Branch 5 not taken.
76427 if(isdungeon() && (y<=26 || y>=world_h - 42) && !get_qr(qr_FREEFORM))
15630 {
15631 shiftdir=-1;
15632 }
15633 else
15634 {
15635
2/2
✓ Branch 0 taken 11503 times.
✓ Branch 1 taken 64924 times.
76427 if(s==left)
15636 {
15637 11503 do
15638 {
15639 13134 info = (walkflag(x-hero_newstep_diag,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep_diag,y+15,1,left));
15640
15641 13134 execute(info);
15642
15643
2/2
✓ Branch 0 taken 3070 times.
✓ Branch 1 taken 10064 times.
13134 if(info.isUnwalkable())
15644 {
15645
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2878 times.
3070 if(x != x.getInt())
15646 {
15647 192 x.doRound();
15648 192 }
15649
2/2
✓ Branch 0 taken 1439 times.
✓ Branch 1 taken 1439 times.
2878 else if(hero_newstep_diag > 1)
15650 {
15651
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1439 times.
1439 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15652 1439 hero_newstep_diag.doFloor();
15653 else --hero_newstep_diag;
15654 1439 }
15655 else
15656 1439 shiftdir = -1;
15657 3070 }
15658
2/2
✓ Branch 0 taken 8469 times.
✓ Branch 1 taken 1595 times.
10064 else if(walkable)
15659 {
15660 8469 do
15661 {
15662 8511 info = walkflag(x-hero_newstep_diag,15+(y+hero_newstep),1,left);
15663 8511 execute(info);
15664
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 8452 times.
8511 if(info.isUnwalkable())
15665 {
15666
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 34 times.
59 if(x != x.getInt())
15667 {
15668 25 x.doRound();
15669 25 }
15670
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 17 times.
34 else if(hero_newstep_diag > 1)
15671 {
15672
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15673 17 hero_newstep_diag.doFloor();
15674 else --hero_newstep_diag;
15675 17 }
15676 else
15677 17 shiftdir = -1;
15678 59 }
15679 8452 else break;
15680
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 17 times.
59 }
15681 59 while(shiftdir != -1);
15682 8469 break;
15683 }
15684 1595 else break;
15685
2/2
✓ Branch 0 taken 1631 times.
✓ Branch 1 taken 1439 times.
3070 }
15686 3070 while(shiftdir != -1);
15687 11503 }
15688
2/2
✓ Branch 0 taken 54233 times.
✓ Branch 1 taken 10691 times.
64924 else if(s==right)
15689 {
15690 10691 do
15691 {
15692 12068 info = (walkflag(x+15+hero_newstep_diag,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep_diag,y+15,1,right));
15693
15694 12068 execute(info);
15695
15696
2/2
✓ Branch 0 taken 2646 times.
✓ Branch 1 taken 9422 times.
12068 if(info.isUnwalkable())
15697 {
15698
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 2548 times.
2646 if(x != x.getInt())
15699 {
15700 98 x.doRound();
15701 98 }
15702
2/2
✓ Branch 0 taken 1279 times.
✓ Branch 1 taken 1269 times.
2548 else if(hero_newstep_diag > 1)
15703 {
15704
1/2
✓ Branch 0 taken 1279 times.
✗ Branch 1 not taken.
1279 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15705 1279 hero_newstep_diag.doFloor();
15706 else --hero_newstep_diag;
15707 1279 }
15708 else
15709 1269 shiftdir = -1;
15710 2646 }
15711
2/2
✓ Branch 0 taken 7796 times.
✓ Branch 1 taken 1626 times.
9422 else if(walkable)
15712 {
15713 7796 do
15714 {
15715 7842 info = walkflag(x+15+hero_newstep_diag,15+(y+hero_newstep),1,right);
15716 7842 execute(info);
15717
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 7767 times.
7842 if(info.isUnwalkable())
15718 {
15719
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 58 times.
75 if(x != x.getInt())
15720 {
15721 17 x.doRound();
15722 17 }
15723
2/2
✓ Branch 0 taken 29 times.
✓ Branch 1 taken 29 times.
58 else if(hero_newstep_diag > 1)
15724 {
15725
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15726 29 hero_newstep_diag.doFloor();
15727 else --hero_newstep_diag;
15728 29 }
15729 else
15730 29 shiftdir = -1;
15731 75 }
15732 7767 else break;
15733
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 29 times.
75 }
15734 75 while(shiftdir != -1);
15735 7796 break;
15736 }
15737 1626 else break;
15738
2/2
✓ Branch 0 taken 1377 times.
✓ Branch 1 taken 1269 times.
2646 }
15739 2646 while(shiftdir != -1);
15740 10691 }
15741 }
15742
15743 76427 moveOld2(down);
15744 76427 shiftdir=s;
15745
15746
2/2
✓ Branch 0 taken 68045 times.
✓ Branch 1 taken 8382 times.
76427 if(!walkable)
15747 {
15748
2/2
✓ Branch 0 taken 3482 times.
✓ Branch 1 taken 4900 times.
8382 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15749 {
15750 4900 x = x.getInt();
15751 4900 y = y.getInt();
15752
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✓ Branch 2 taken 4900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3632 times.
✓ Branch 5 taken 1268 times.
✓ Branch 6 taken 515 times.
✓ Branch 7 taken 4385 times.
6168 if(!_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
15753
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1268 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1268 times.
✓ Branch 4 taken 706 times.
✓ Branch 5 taken 562 times.
1268 !_walkflag(x+8, y+15+1,1,STANDING_Z_STATE)&&
15754
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 562 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 562 times.
562 _walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
15755 {
15756
9/12
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 511 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 511 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 507 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 507 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 515 times.
515 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
15757 515 sprite::move((zfix)-1,(zfix)0);
15758 515 }
15759
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4385 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4385 times.
✓ Branch 4 taken 753 times.
✓ Branch 5 taken 3632 times.
✓ Branch 6 taken 513 times.
✓ Branch 7 taken 3872 times.
8017 else if(_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
15760
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3632 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3632 times.
✓ Branch 4 taken 3119 times.
✓ Branch 5 taken 513 times.
3632 !_walkflag(x+7, y+15+1,1,STANDING_Z_STATE)&&
15761
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 513 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 513 times.
513 !_walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
15762 {
15763
7/12
✓ Branch 0 taken 507 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 507 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 507 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 507 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 507 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 513 times.
513 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
15764 513 sprite::move((zfix)1,(zfix)0);
15765 513 }
15766 else
15767 {
15768 3872 pushing=push+1;
15769 }
15770 4900 }
15771 else
15772 {
15773 3482 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
15774 }
15775 8382 }
15776
15777 76427 return;
15778 }
15779 }
15780
15781
6/6
✓ Branch 0 taken 105626 times.
✓ Branch 1 taken 301523 times.
✓ Branch 2 taken 102124 times.
✓ Branch 3 taken 3502 times.
✓ Branch 4 taken 102023 times.
✓ Branch 5 taken 101 times.
407149 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == left))
15782 {
15783
5/8
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 102533 times.
✓ Branch 2 taken 2945 times.
✓ Branch 3 taken 47 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2992 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
105525 if(isdungeon() && (y<=26 || y>=world_h - 42) && !get_qr(qr_FREEFORM) && !toogam)
15784 {
15785 }
15786 else
15787 {
15788
4/6
✓ Branch 0 taken 105126 times.
✓ Branch 1 taken 399 times.
✓ Branch 2 taken 105126 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 105126 times.
105525 if(charging==0 && spins==0 && action != sideswimattacking)
15789 {
15790 105126 dir=left;
15791 105126 }
15792 105525 sideswimdir = left;
15793
15794 105525 holddir=left;
15795
15796
4/4
✓ Branch 0 taken 12469 times.
✓ Branch 1 taken 93056 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12468 times.
105525 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != down)
15797 {
15798 12468 shiftdir=up;
15799 12468 }
15800
4/4
✓ Branch 0 taken 11444 times.
✓ Branch 1 taken 81613 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11442 times.
93057 else if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != up)
15801 {
15802 11442 shiftdir=down;
15803 11442 }
15804 else
15805 {
15806 81615 shiftdir=-1;
15807 }
15808
15809 105525 do
15810 {
15811 116860 info = walkflag(x-hero_newstep,y+(bigHitbox?0:8),1,left)||walkflag(x-hero_newstep,y+8,1,left);
15812
15813 116860 info = info || walkflag(x-hero_newstep,y+15,1,left);
15814
15815 116860 execute(info);
15816
15817
2/2
✓ Branch 0 taken 21300 times.
✓ Branch 1 taken 95560 times.
116860 if(info.isUnwalkable())
15818 {
15819
2/2
✓ Branch 0 taken 1372 times.
✓ Branch 1 taken 19928 times.
21300 if(x != x.getInt())
15820 {
15821 1372 x.doRound();
15822 1372 }
15823
2/2
✓ Branch 0 taken 9963 times.
✓ Branch 1 taken 9965 times.
19928 else if(hero_newstep > 1)
15824 {
15825
1/2
✓ Branch 0 taken 9963 times.
✗ Branch 1 not taken.
9963 if(hero_newstep != int32_t(hero_newstep)) //floor
15826 9963 hero_newstep = floor((double)hero_newstep);
15827 else --hero_newstep;
15828 9963 }
15829 else
15830 9965 break;
15831 11335 }
15832 95560 else walkable = true;
15833
2/2
✓ Branch 0 taken 11335 times.
✓ Branch 1 taken 95560 times.
106895 }
15834 106895 while(!walkable);
15835
15836 105525 int32_t s=shiftdir;
15837
15838
10/14
✓ Branch 0 taken 2992 times.
✓ Branch 1 taken 102533 times.
✓ Branch 2 taken 2948 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 2992 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 894 times.
✓ Branch 7 taken 104631 times.
✓ Branch 8 taken 894 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 894 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 894 times.
✗ Branch 13 not taken.
105525 if((isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
15839 {
15840 894 shiftdir=-1;
15841 894 }
15842 else
15843 {
15844
2/2
✓ Branch 0 taken 92163 times.
✓ Branch 1 taken 12468 times.
104631 if(s==up)
15845 {
15846 12468 do
15847 {
15848 14161 zfix ty = y - hero_newstep_diag;
15849 28322 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
15850 14161 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
15851
15852
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14154 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
14161 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15853 {
15854 7 info = info || walkflag(x, 0_zf, 2, up);
15855 7 info = info || walkflag(x+15, 0_zf, 1, up);
15856 7 }
15857 14161 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
15858
15859 14161 execute(info);
15860
15861
2/2
✓ Branch 0 taken 3189 times.
✓ Branch 1 taken 10972 times.
14161 if(info.isUnwalkable())
15862 {
15863
2/2
✓ Branch 0 taken 197 times.
✓ Branch 1 taken 2992 times.
3189 if(y != y.getInt())
15864 {
15865 197 y.doRound();
15866 197 }
15867
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 1496 times.
2992 else if(hero_newstep_diag > 1)
15868 {
15869
1/2
✓ Branch 0 taken 1496 times.
✗ Branch 1 not taken.
1496 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15870 1496 hero_newstep_diag.doFloor();
15871 else --hero_newstep_diag;
15872 1496 }
15873 else
15874 1496 shiftdir = -1;
15875 3189 }
15876
2/2
✓ Branch 0 taken 9302 times.
✓ Branch 1 taken 1670 times.
10972 else if(walkable)
15877 {
15878 9302 do
15879 {
15880 9361 zfix tx = x-hero_newstep, ty = y-hero_newstep_diag;
15881 9361 info = walkflag(tx,(bigHitbox?0:8)+ty,1,up);
15882
15883
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9354 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9361 if (ty < 0 && !bigHitbox) //sanity check for up scroll
15884 {
15885 7 info = info || walkflag(tx, 0_zf, 1, up);
15886 7 info = info || walkflag(tx+15, 0_zf, 1, up);
15887 7 }
15888 9361 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
15889
15890 9361 execute(info);
15891
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 9264 times.
9361 if(info.isUnwalkable())
15892 {
15893
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 76 times.
97 if(y != y.getInt())
15894 {
15895 21 y.doRound();
15896 21 }
15897
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 38 times.
76 else if(hero_newstep_diag > 1)
15898 {
15899
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15900 38 hero_newstep_diag.doFloor();
15901 else --hero_newstep_diag;
15902 38 }
15903 else
15904 38 shiftdir = -1;
15905 97 }
15906 9264 else break;
15907
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 38 times.
97 }
15908 97 while(shiftdir != -1);
15909 9302 break;
15910 }
15911 1670 else break;
15912
2/2
✓ Branch 0 taken 1693 times.
✓ Branch 1 taken 1496 times.
3189 }
15913 3189 while(shiftdir != -1);
15914 12468 }
15915
2/2
✓ Branch 0 taken 80721 times.
✓ Branch 1 taken 11442 times.
92163 else if(s==down)
15916 {
15917 11442 do
15918 {
15919 13536 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
15920
15921 13536 execute(info);
15922
15923
2/2
✓ Branch 0 taken 3941 times.
✓ Branch 1 taken 9595 times.
13536 if(info.isUnwalkable())
15924 {
15925
2/2
✓ Branch 0 taken 201 times.
✓ Branch 1 taken 3740 times.
3941 if(y != y.getInt())
15926 {
15927 201 y.doRound();
15928 201 }
15929
2/2
✓ Branch 0 taken 1893 times.
✓ Branch 1 taken 1847 times.
3740 else if(hero_newstep_diag > 1)
15930 {
15931
1/2
✓ Branch 0 taken 1893 times.
✗ Branch 1 not taken.
1893 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15932 1893 hero_newstep_diag.doFloor();
15933 else --hero_newstep_diag;
15934 1893 }
15935 else
15936 1847 shiftdir = -1;
15937 3941 }
15938
2/2
✓ Branch 0 taken 7952 times.
✓ Branch 1 taken 1643 times.
9595 else if(walkable)
15939 {
15940 7952 do
15941 {
15942 7970 info = walkflag(x-hero_newstep,y+15+hero_newstep_diag,1,down);
15943 7970 execute(info);
15944
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 7938 times.
7970 if(info.isUnwalkable())
15945 {
15946
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 28 times.
32 if(y != y.getInt())
15947 {
15948 4 y.doRound();
15949 4 }
15950
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 else if(hero_newstep_diag > 1)
15951 {
15952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
15953 14 hero_newstep_diag.doFloor();
15954 else --hero_newstep_diag;
15955 14 }
15956 else
15957 14 shiftdir = -1;
15958 32 }
15959 7938 else break;
15960
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
32 }
15961 32 while(shiftdir != -1);
15962 7952 break;
15963 }
15964 1643 else break;
15965
2/2
✓ Branch 0 taken 2094 times.
✓ Branch 1 taken 1847 times.
3941 }
15966 3941 while(shiftdir != -1);
15967 11442 }
15968 }
15969
15970 105525 moveOld2(left);
15971 105525 shiftdir=s;
15972
15973
2/2
✓ Branch 0 taken 95560 times.
✓ Branch 1 taken 9965 times.
105525 if(!walkable)
15974 {
15975
2/2
✓ Branch 0 taken 3680 times.
✓ Branch 1 taken 6285 times.
9965 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
15976 {
15977 6285 x = x.getInt();
15978 6285 y = y.getInt();
15979 6285 int32_t v1=bigHitbox?0:8;
15980 6285 int32_t v2=bigHitbox?8:12;
15981
15982
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6285 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6285 times.
✓ Branch 4 taken 5067 times.
✓ Branch 5 taken 1218 times.
✓ Branch 6 taken 156 times.
✓ Branch 7 taken 6129 times.
7503 if(!_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
15983
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1218 times.
✓ Branch 4 taken 597 times.
✓ Branch 5 taken 621 times.
1218 !_walkflag(x-1,y+v2,1,STANDING_Z_STATE)&&
15984
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 621 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 621 times.
621 _walkflag(x-1,y+15,1,STANDING_Z_STATE))
15985 {
15986
9/12
✓ Branch 0 taken 149 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 146 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 146 times.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 156 times.
156 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
15987 156 sprite::move((zfix)0,(zfix)-1);
15988 156 }
15989
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6129 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6129 times.
✓ Branch 4 taken 1062 times.
✓ Branch 5 taken 5067 times.
✓ Branch 6 taken 195 times.
✓ Branch 7 taken 5934 times.
11196 else if(_walkflag(x-1,y+v1, 1,STANDING_Z_STATE)&&
15990
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 5067 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5067 times.
✓ Branch 4 taken 4872 times.
✓ Branch 5 taken 195 times.
5067 !_walkflag(x-1,y+v2-1,1,STANDING_Z_STATE)&&
15991
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 195 times.
195 !_walkflag(x-1,y+15, 1,STANDING_Z_STATE))
15992 {
15993
7/12
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 194 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 194 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 194 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 194 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 195 times.
195 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
15994 195 sprite::move((zfix)0,(zfix)1);
15995 195 }
15996 else
15997 {
15998 5934 pushing=push+1;
15999 }
16000 6285 }
16001 else
16002 {
16003 3680 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16004
16005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3680 times.
3680 if(action!=swimming)
16006 {
16007 3680 }
16008 }
16009 9965 }
16010
16011 105525 return;
16012 }
16013 }
16014
16015
5/6
✓ Branch 0 taken 108312 times.
✓ Branch 1 taken 193312 times.
✓ Branch 2 taken 104710 times.
✓ Branch 3 taken 3602 times.
✓ Branch 4 taken 104710 times.
✗ Branch 5 not taken.
301624 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == right))
16016 {
16017
5/8
✓ Branch 0 taken 3423 times.
✓ Branch 1 taken 104889 times.
✓ Branch 2 taken 3321 times.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3423 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
108312 if(isdungeon() && (y<=26 || y>=world_h - 42) && !get_qr(qr_FREEFORM) && !toogam)
16018 {
16019 }
16020 else
16021 {
16022
4/6
✓ Branch 0 taken 107610 times.
✓ Branch 1 taken 702 times.
✓ Branch 2 taken 107610 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 107610 times.
108312 if(charging==0 && spins==0 && action != sideswimattacking)
16023 {
16024 107610 dir=right;
16025 107610 }
16026 108312 sideswimdir = right;
16027
16028 108312 holddir=right;
16029
16030
4/4
✓ Branch 0 taken 11938 times.
✓ Branch 1 taken 96374 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11937 times.
108312 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != down)
16031 {
16032 11937 shiftdir=up;
16033 11937 }
16034
4/4
✓ Branch 0 taken 10841 times.
✓ Branch 1 taken 85534 times.
✓ Branch 2 taken 10837 times.
✓ Branch 3 taken 4 times.
96375 else if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != up)
16035 {
16036 10837 shiftdir=down;
16037 10837 }
16038 else
16039 {
16040 85538 shiftdir=-1;
16041 }
16042
16043 108312 do
16044 {
16045 119870 info = walkflag(x+15+hero_newstep,y+(bigHitbox?0:8),1,right)||walkflag(x+15+hero_newstep,y+8,1,right);;
16046
16047 119870 info = info || walkflag(x+15+hero_newstep,y+15,1,right);
16048
16049 119870 execute(info);
16050
16051
2/2
✓ Branch 0 taken 21932 times.
✓ Branch 1 taken 97938 times.
119870 if(info.isUnwalkable())
16052 {
16053
2/2
✓ Branch 0 taken 787 times.
✓ Branch 1 taken 21145 times.
21932 if(x != x.getInt())
16054 {
16055 787 x.doRound();
16056 787 }
16057
2/2
✓ Branch 0 taken 10771 times.
✓ Branch 1 taken 10374 times.
21145 else if(hero_newstep > 1)
16058 {
16059
1/2
✓ Branch 0 taken 10771 times.
✗ Branch 1 not taken.
10771 if(hero_newstep != int32_t(hero_newstep)) //floor
16060 10771 hero_newstep = floor((double)hero_newstep);
16061 else --hero_newstep;
16062 10771 }
16063 else
16064 10374 break;
16065 11558 }
16066 97938 else walkable = true;
16067
2/2
✓ Branch 0 taken 11558 times.
✓ Branch 1 taken 97938 times.
109496 }
16068 109496 while(!walkable);
16069
16070 108312 int32_t s=shiftdir;
16071
16072
10/14
✓ Branch 0 taken 3423 times.
✓ Branch 1 taken 104889 times.
✓ Branch 2 taken 3373 times.
✓ Branch 3 taken 50 times.
✓ Branch 4 taken 3423 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1560 times.
✓ Branch 7 taken 106752 times.
✓ Branch 8 taken 1560 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1560 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1560 times.
✗ Branch 13 not taken.
108312 if((isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16073 {
16074 1560 shiftdir=-1;
16075 1560 }
16076 else
16077 {
16078
2/2
✓ Branch 0 taken 94815 times.
✓ Branch 1 taken 11937 times.
106752 if(s==up)
16079 {
16080 11937 do
16081 {
16082 13313 zfix ty = y - hero_newstep_diag;
16083 26626 info = walkflag(x,(bigHitbox?0:8) + ty,2,up)
16084 13313 || walkflag(x+15,(bigHitbox?0:8) + ty,1,up);
16085
16086
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 13306 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
13313 if (ty < 0 && !bigHitbox) //sanity check for up scroll
16087 {
16088 7 info = info || walkflag(x, 0_zf, 2, up);
16089 7 info = info || walkflag(x+15, 0_zf, 1, up);
16090 7 }
16091 13313 info = info || walkflagMBlock(x+15, (bigHitbox?0:8) + ty);
16092
16093 13313 execute(info);
16094
16095
2/2
✓ Branch 0 taken 2558 times.
✓ Branch 1 taken 10755 times.
13313 if(info.isUnwalkable())
16096 {
16097
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 2364 times.
2558 if(y != y.getInt())
16098 {
16099 194 y.doRound();
16100 194 }
16101
2/2
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 1182 times.
2364 else if(hero_newstep_diag > 1)
16102 {
16103
1/2
✓ Branch 0 taken 1182 times.
✗ Branch 1 not taken.
1182 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16104 1182 hero_newstep_diag.doFloor();
16105 else --hero_newstep_diag;
16106 1182 }
16107 else
16108 1182 shiftdir = -1;
16109 2558 }
16110
2/2
✓ Branch 0 taken 9440 times.
✓ Branch 1 taken 1315 times.
10755 else if(walkable)
16111 {
16112 9440 do
16113 {
16114 9488 zfix tx = x+hero_newstep, ty = y-hero_newstep_diag;
16115 9488 info = walkflag(tx+15,(bigHitbox?0:8)+ty,1,up);
16116
16117
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 9483 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
9488 if (ty < 0 && !bigHitbox) //sanity check for up scroll
16118 {
16119 5 info = info || walkflag(tx, 0_zf, 1, up);
16120 5 info = info || walkflag(tx+15, 0_zf, 1, up);
16121 5 }
16122 9488 info = info || walkflagMBlock(tx+15, (bigHitbox?0:8) + ty);
16123 9488 execute(info);
16124
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 9413 times.
9488 if(info.isUnwalkable())
16125 {
16126
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 54 times.
75 if(y != y.getInt())
16127 {
16128 21 y.doRound();
16129 21 }
16130
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 27 times.
54 else if(hero_newstep_diag > 1)
16131 {
16132
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16133 27 hero_newstep_diag.doFloor();
16134 else --hero_newstep_diag;
16135 27 }
16136 else
16137 27 shiftdir = -1;
16138 75 }
16139 9413 else break;
16140
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 27 times.
75 }
16141 75 while(shiftdir != -1);
16142 9440 break;
16143 }
16144 1315 else break;
16145
2/2
✓ Branch 0 taken 1376 times.
✓ Branch 1 taken 1182 times.
2558 }
16146 2558 while(shiftdir != -1);
16147 11937 }
16148
2/2
✓ Branch 0 taken 83978 times.
✓ Branch 1 taken 10837 times.
94815 else if(s==down)
16149 {
16150 10837 do
16151 {
16152 12652 info = walkflag(x,y+15+hero_newstep_diag,2,down)||walkflag(x+15,y+15+hero_newstep_diag,1,down);
16153
16154 12652 execute(info);
16155
16156
2/2
✓ Branch 0 taken 3373 times.
✓ Branch 1 taken 9279 times.
12652 if(info.isUnwalkable())
16157 {
16158
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 3164 times.
3373 if(y != y.getInt())
16159 {
16160 209 y.doRound();
16161 209 }
16162
2/2
✓ Branch 0 taken 1558 times.
✓ Branch 1 taken 1606 times.
3164 else if(hero_newstep_diag > 1)
16163 {
16164
1/2
✓ Branch 0 taken 1606 times.
✗ Branch 1 not taken.
1606 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16165 1606 hero_newstep_diag.doFloor();
16166 else --hero_newstep_diag;
16167 1606 }
16168 else
16169 1558 shiftdir = -1;
16170 3373 }
16171
2/2
✓ Branch 0 taken 7880 times.
✓ Branch 1 taken 1399 times.
9279 else if(walkable)
16172 {
16173 7880 do
16174 {
16175 7913 info = walkflag(x+15+hero_newstep,y+15+hero_newstep_diag,1,down);
16176 7913 execute(info);
16177
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 7859 times.
7913 if(info.isUnwalkable())
16178 {
16179
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 44 times.
54 if(y != y.getInt())
16180 {
16181 10 y.doRound();
16182 10 }
16183
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 23 times.
44 else if(hero_newstep_diag > 1)
16184 {
16185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(hero_newstep_diag != hero_newstep_diag.getInt()) //floor
16186 23 hero_newstep_diag.doFloor();
16187 else --hero_newstep_diag;
16188 23 }
16189 else
16190 21 shiftdir = -1;
16191 54 }
16192 7859 else break;
16193
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 21 times.
54 }
16194 54 while(shiftdir != -1);
16195 7880 break;
16196 }
16197 1399 else break;
16198
2/2
✓ Branch 0 taken 1815 times.
✓ Branch 1 taken 1558 times.
3373 }
16199 3373 while(shiftdir != -1);
16200 10837 }
16201 }
16202
16203 108312 moveOld2(right);
16204 108312 shiftdir=s;
16205
16206
2/2
✓ Branch 0 taken 97938 times.
✓ Branch 1 taken 10374 times.
108312 if(!walkable)
16207 {
16208
2/2
✓ Branch 0 taken 2939 times.
✓ Branch 1 taken 7435 times.
10374 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16209 {
16210 7435 x = x.getInt();
16211 7435 y = y.getInt();
16212 7435 int32_t v1=bigHitbox?0:8;
16213 7435 int32_t v2=bigHitbox?8:12;
16214
16215
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7435 times.
✓ Branch 2 taken 7435 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6276 times.
✓ Branch 5 taken 1159 times.
✓ Branch 6 taken 238 times.
✓ Branch 7 taken 7197 times.
8594 if(!_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
16216
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1159 times.
✓ Branch 4 taken 701 times.
✓ Branch 5 taken 458 times.
1159 !_walkflag(x+16,y+v2,1,STANDING_Z_STATE)&&
16217
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 458 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 458 times.
458 _walkflag(x+16,y+15,1,STANDING_Z_STATE))
16218 {
16219
7/12
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 231 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 231 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 231 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 231 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 238 times.
238 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16220 238 sprite::move((zfix)0,(zfix)-1);
16221 238 }
16222
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 7197 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7197 times.
✓ Branch 4 taken 921 times.
✓ Branch 5 taken 6276 times.
✓ Branch 6 taken 254 times.
✓ Branch 7 taken 6943 times.
13473 else if(_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
16223
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6276 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6276 times.
✓ Branch 4 taken 6022 times.
✓ Branch 5 taken 254 times.
6276 !_walkflag(x+16,y+v2-1,1,STANDING_Z_STATE)&&
16224
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 254 times.
254 !_walkflag(x+16,y+15,1,STANDING_Z_STATE))
16225 {
16226
9/12
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 253 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 253 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 250 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 250 times.
✓ Branch 9 taken 3 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 254 times.
254 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16227 254 sprite::move((zfix)0,(zfix)1);
16228 254 }
16229 else
16230 {
16231 6943 pushing=push+1;
16232 6943 z3step=2;
16233 }
16234 7435 }
16235 else
16236 {
16237 2939 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16238
16239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2939 times.
2939 if(action!=swimming)
16240 {
16241 2939 }
16242 }
16243 10374 }
16244
16245 108312 return;
16246 }
16247 }
16248 193312 }
16249 else
16250 {
16251
6/6
✓ Branch 0 taken 605306 times.
✓ Branch 1 taken 2496131 times.
✓ Branch 2 taken 591459 times.
✓ Branch 3 taken 13847 times.
✓ Branch 4 taken 120553 times.
✓ Branch 5 taken 470906 times.
3101437 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == up))
16252 {
16253
5/8
✓ Branch 0 taken 3903 times.
✓ Branch 1 taken 480850 times.
✓ Branch 2 taken 3899 times.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3903 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
484753 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
16254 {
16255 }
16256 else
16257 {
16258
3/4
✓ Branch 0 taken 440629 times.
✓ Branch 1 taken 44124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 440629 times.
484753 if(charging==0 && spins==0)
16259 {
16260 440629 dir=up;
16261 440629 }
16262
16263 484753 holddir=up;
16264
16265
4/4
✓ Branch 0 taken 64206 times.
✓ Branch 1 taken 340161 times.
✓ Branch 2 taken 110 times.
✓ Branch 3 taken 64096 times.
484753 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != left)
16266 {
16267 64096 shiftdir=right;
16268 64096 }
16269
4/4
✓ Branch 0 taken 52930 times.
✓ Branch 1 taken 287341 times.
✓ Branch 2 taken 80 times.
✓ Branch 3 taken 52850 times.
340271 else if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != right)
16270 {
16271 52850 shiftdir=left;
16272 52850 }
16273 else
16274 {
16275 287421 shiftdir=-1;
16276 }
16277
16278 //walkable if Ladder can be placed or is already placed vertically
16279
10/18
✓ Branch 0 taken 21030 times.
✓ Branch 1 taken 383337 times.
✓ Branch 2 taken 21030 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 21030 times.
✓ Branch 6 taken 21030 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 20899 times.
✓ Branch 11 taken 20899 times.
✓ Branch 12 taken 20899 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20899 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 20899 times.
404367 if(isSideViewHero() && !toogam && !(((replay_version_check(0, 23) || get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) && can_deploy_ladder()) || (ladderx && laddery && ladderdir==up)) && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16280 {
16281 20899 walkable=false;
16282 20899 }
16283 else
16284 {
16285
7/8
✓ Branch 0 taken 57465 times.
✓ Branch 1 taken 367801 times.
✓ Branch 2 taken 787 times.
✓ Branch 3 taken 56678 times.
✓ Branch 4 taken 963 times.
✓ Branch 5 taken 423516 times.
✓ Branch 6 taken 963 times.
✗ Branch 7 not taken.
425266 if ((can_deploy_ladder() && get_qr(qr_OLD_LADDER_ITEM_SIDEVIEW)) || (ladderx && laddery && ladderdir==up)) justmoved = 2;
16286 425266 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
16287
16288
2/2
✓ Branch 0 taken 231559 times.
✓ Branch 1 taken 193707 times.
425266 if(x.getInt() & 7)
16289 231559 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
16290 else
16291 193707 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
16292
16293 425266 execute(info);
16294
16295
2/2
✓ Branch 0 taken 66936 times.
✓ Branch 1 taken 358330 times.
425266 if(info.isUnwalkable())
16296 {
16297
2/2
✓ Branch 0 taken 65594 times.
✓ Branch 1 taken 1342 times.
66936 if(z3step==2)
16298 {
16299 65594 z3step=1;
16300 65594 info = walkflag(x,y+(bigHitbox?0:8)-z3step,2,up);
16301
16302
2/2
✓ Branch 0 taken 28001 times.
✓ Branch 1 taken 37593 times.
65594 if(x.getInt()&7)
16303 37593 info = info || walkflag(x+16,y+(bigHitbox?0:8)-z3step,1,up);
16304 else
16305 28001 info = info || walkflagMBlock(x+16, y+(bigHitbox?0:8)-z3step);
16306
16307 65594 execute(info);
16308
16309
2/2
✓ Branch 0 taken 60487 times.
✓ Branch 1 taken 5107 times.
65594 if(info.isUnwalkable())
16310 {
16311 60487 walkable = false;
16312 60487 }
16313 else
16314 {
16315 5107 walkable=true;
16316 }
16317 65594 }
16318 else
16319 {
16320 1342 walkable=false;
16321 }
16322 66936 }
16323 else
16324 {
16325 358330 walkable = true;
16326 }
16327 }
16328
16329 446165 int32_t s=shiftdir;
16330
16331
5/6
✓ Branch 0 taken 3903 times.
✓ Branch 1 taken 442262 times.
✓ Branch 2 taken 3784 times.
✓ Branch 3 taken 119 times.
✓ Branch 4 taken 3903 times.
✗ Branch 5 not taken.
446165 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM))
16332 {
16333 shiftdir=-1;
16334 }
16335 else
16336 {
16337
2/2
✓ Branch 0 taken 52850 times.
✓ Branch 1 taken 393315 times.
446165 if(s==left)
16338 {
16339 52850 info = (walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left));
16340 52850 execute(info);
16341
16342
2/2
✓ Branch 0 taken 7278 times.
✓ Branch 1 taken 45572 times.
52850 if(info.isUnwalkable())
16343 {
16344 7278 shiftdir=-1;
16345 7278 }
16346
2/2
✓ Branch 0 taken 9498 times.
✓ Branch 1 taken 36074 times.
45572 else if(walkable)
16347 {
16348 36074 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,left);
16349 36074 execute(info);
16350
2/2
✓ Branch 0 taken 35991 times.
✓ Branch 1 taken 83 times.
36074 if(info.isUnwalkable())
16351 {
16352 83 shiftdir=-1;
16353 83 }
16354 36074 }
16355 52850 }
16356
2/2
✓ Branch 0 taken 329219 times.
✓ Branch 1 taken 64096 times.
393315 else if(s==right)
16357 {
16358 64096 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
16359 64096 execute(info);
16360
16361
2/2
✓ Branch 0 taken 9315 times.
✓ Branch 1 taken 54781 times.
64096 if(info.isUnwalkable())
16362 {
16363 9315 shiftdir=-1;
16364 9315 }
16365
2/2
✓ Branch 0 taken 11126 times.
✓ Branch 1 taken 43655 times.
54781 else if(walkable)
16366 {
16367 43655 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,right);
16368 43655 execute(info);
16369
16370
2/2
✓ Branch 0 taken 43569 times.
✓ Branch 1 taken 86 times.
43655 if(info.isUnwalkable())
16371 {
16372 86 shiftdir=-1;
16373 86 }
16374 43655 }
16375 64096 }
16376 }
16377
16378 446165 moveOld2(up);
16379 446165 shiftdir=s;
16380
16381
2/2
✓ Branch 0 taken 363437 times.
✓ Branch 1 taken 82728 times.
446165 if(!walkable)
16382 {
16383
2/2
✓ Branch 0 taken 25064 times.
✓ Branch 1 taken 57664 times.
82728 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16384 {
16385
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 57664 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 57664 times.
✓ Branch 4 taken 29302 times.
✓ Branch 5 taken 28362 times.
✓ Branch 6 taken 2488 times.
✓ Branch 7 taken 55176 times.
86026 if(!_walkflag(x, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16386
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28362 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28362 times.
✓ Branch 4 taken 5838 times.
✓ Branch 5 taken 22524 times.
28362 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16387
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22524 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22524 times.
22524 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
16388 {
16389
9/12
✓ Branch 0 taken 2417 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 2417 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2417 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2389 times.
✓ Branch 7 taken 28 times.
✓ Branch 8 taken 2389 times.
✓ Branch 9 taken 28 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2488 times.
2488 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
16390 2488 sprite::move((zfix)-1,(zfix)0);
16391 2488 }
16392 else
16393 {
16394
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 55176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55176 times.
✓ Branch 4 taken 25874 times.
✓ Branch 5 taken 29302 times.
✓ Branch 6 taken 2472 times.
✓ Branch 7 taken 52704 times.
84478 if(_walkflag(x, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16395
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 29302 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29302 times.
✓ Branch 4 taken 26830 times.
✓ Branch 5 taken 2472 times.
29302 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
16396
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2472 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2472 times.
2472 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
16397 {
16398
10/12
✓ Branch 0 taken 2383 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 2383 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2383 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2370 times.
✓ Branch 7 taken 13 times.
✓ Branch 8 taken 2370 times.
✓ Branch 9 taken 13 times.
✓ Branch 10 taken 2 times.
✓ Branch 11 taken 2470 times.
2472 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
16399 2470 sprite::move((zfix)1,(zfix)0);
16400 2472 }
16401 else
16402 {
16403 52704 pushing=push+1;
16404 }
16405 }
16406
16407 57664 z3step=2;
16408 57664 }
16409 else
16410 {
16411 25064 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16412 25064 z3step=2;
16413 }
16414 82728 }
16415
16416 446165 return;
16417 }
16418 }
16419
16420
6/6
✓ Branch 0 taken 505248 times.
✓ Branch 1 taken 2111436 times.
✓ Branch 2 taken 493208 times.
✓ Branch 3 taken 12040 times.
✓ Branch 4 taken 365430 times.
✓ Branch 5 taken 127778 times.
2616684 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == down))
16421 {
16422
4/8
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 374795 times.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2675 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
377470 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
16423 {
16424 }
16425 else
16426 {
16427
3/4
✓ Branch 0 taken 372454 times.
✓ Branch 1 taken 5016 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 372454 times.
377470 if(charging==0 && spins==0)
16428 {
16429 372454 dir=down;
16430 372454 }
16431
16432 377470 holddir=down;
16433
16434
4/4
✓ Branch 0 taken 62738 times.
✓ Branch 1 taken 314732 times.
✓ Branch 2 taken 298 times.
✓ Branch 3 taken 62440 times.
377470 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != left)
16435 {
16436 62440 shiftdir=right;
16437 62440 }
16438
4/4
✓ Branch 0 taken 58119 times.
✓ Branch 1 taken 256911 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 58035 times.
315030 else if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != right)
16439 {
16440 58035 shiftdir=left;
16441 58035 }
16442 else
16443 {
16444 256995 shiftdir=-1;
16445 }
16446
16447 //bool walkable;
16448
7/12
✓ Branch 0 taken 12293 times.
✓ Branch 1 taken 365177 times.
✓ Branch 2 taken 12293 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12293 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12293 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12293 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 12293 times.
377470 if(isSideViewHero() && !toogam && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
16449 {
16450 12293 walkable=false;
16451 12293 }
16452 else
16453 {
16454 365177 info = walkflag(x,y+15+z3step,2,down);
16455
16456
2/2
✓ Branch 0 taken 202261 times.
✓ Branch 1 taken 162916 times.
365177 if(x.getInt()&7)
16457 202261 info = info || walkflag(x+16,y+15+z3step,1,down);
16458 else
16459 162916 info = info || walkflagMBlock(x+16, y+15+z3step);
16460
16461 365177 execute(info);
16462
16463
2/2
✓ Branch 0 taken 64896 times.
✓ Branch 1 taken 300281 times.
365177 if(info.isUnwalkable())
16464 {
16465
2/2
✓ Branch 0 taken 63721 times.
✓ Branch 1 taken 1175 times.
64896 if(z3step==2)
16466 {
16467 63721 z3step=1;
16468 63721 info = walkflag(x,y+15+z3step,2,down);
16469
16470
2/2
✓ Branch 0 taken 24935 times.
✓ Branch 1 taken 38786 times.
63721 if(x.getInt()&7)
16471 38786 info = info || walkflag(x+16,y+15+z3step,1,down);
16472 else
16473 24935 info = info || walkflagMBlock(x+16, y+15+z3step);
16474
16475 63721 execute(info);
16476
16477
2/2
✓ Branch 0 taken 59220 times.
✓ Branch 1 taken 4501 times.
63721 if(info.isUnwalkable())
16478 {
16479 59220 walkable = false;
16480 59220 }
16481 else
16482 {
16483 4501 walkable=true;
16484 }
16485 63721 }
16486 else
16487 {
16488 1175 walkable=false;
16489 }
16490 64896 }
16491 else
16492 {
16493 300281 walkable = true;
16494 }
16495 }
16496
16497 377470 int32_t s=shiftdir;
16498
16499
5/6
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 374795 times.
✓ Branch 2 taken 2670 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 2675 times.
✗ Branch 5 not taken.
377470 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM))
16500 {
16501 shiftdir=-1;
16502 }
16503 else
16504 {
16505
2/2
✓ Branch 0 taken 58035 times.
✓ Branch 1 taken 319435 times.
377470 if(s==left)
16506 {
16507 58035 info = walkflag(x-1,y+(bigHitbox?0:8),1,left)||walkflag(x-1,y+15,1,left);
16508 58035 execute(info);
16509
16510
2/2
✓ Branch 0 taken 6894 times.
✓ Branch 1 taken 51141 times.
58035 if(info.isUnwalkable())
16511 {
16512 6894 shiftdir=-1;
16513 6894 }
16514
2/2
✓ Branch 0 taken 12561 times.
✓ Branch 1 taken 38580 times.
51141 else if(walkable)
16515 {
16516 38580 info = walkflag(x-1,y+16,1,left);
16517 38580 execute(info);
16518
16519
2/2
✓ Branch 0 taken 38500 times.
✓ Branch 1 taken 80 times.
38580 if(info.isUnwalkable())
16520 {
16521 80 shiftdir=-1;
16522 80 }
16523 38580 }
16524 58035 }
16525
2/2
✓ Branch 0 taken 256995 times.
✓ Branch 1 taken 62440 times.
319435 else if(s==right)
16526 {
16527 62440 info = walkflag(x+16,y+(bigHitbox?0:8),1,right)||walkflag(x+16,y+15,1,right);
16528 62440 execute(info);
16529
16530
2/2
✓ Branch 0 taken 10015 times.
✓ Branch 1 taken 52425 times.
62440 if(info.isUnwalkable())
16531 {
16532 10015 shiftdir=-1;
16533 10015 }
16534
2/2
✓ Branch 0 taken 12539 times.
✓ Branch 1 taken 39886 times.
52425 else if(walkable)
16535 {
16536 39886 info = walkflag(x+16,y+16,1,right);
16537 39886 execute(info);
16538
16539
2/2
✓ Branch 0 taken 39800 times.
✓ Branch 1 taken 86 times.
39886 if(info.isUnwalkable())
16540 {
16541 86 shiftdir=-1;
16542 86 }
16543 39886 }
16544 62440 }
16545 }
16546
16547 377470 moveOld2(down);
16548 377470 shiftdir=s;
16549
16550
2/2
✓ Branch 0 taken 304782 times.
✓ Branch 1 taken 72688 times.
377470 if(!walkable)
16551 {
16552
2/2
✓ Branch 0 taken 31161 times.
✓ Branch 1 taken 41527 times.
72688 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16553 {
16554
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 41527 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 41527 times.
✓ Branch 4 taken 24386 times.
✓ Branch 5 taken 17141 times.
✓ Branch 6 taken 1992 times.
✓ Branch 7 taken 39535 times.
58668 if(!_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
16555
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17141 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17141 times.
✓ Branch 4 taken 5772 times.
✓ Branch 5 taken 11369 times.
17141 !_walkflag(x+8, y+15+1,1,STANDING_Z_STATE)&&
16556
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11369 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11369 times.
11369 _walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
16557 {
16558
9/12
✓ Branch 0 taken 1867 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 1867 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1867 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1859 times.
✓ Branch 7 taken 8 times.
✓ Branch 8 taken 1859 times.
✓ Branch 9 taken 8 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1992 times.
1992 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
16559 1992 sprite::move((zfix)-1,(zfix)0);
16560 1992 }
16561
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 39535 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39535 times.
✓ Branch 4 taken 15149 times.
✓ Branch 5 taken 24386 times.
✓ Branch 6 taken 1804 times.
✓ Branch 7 taken 37731 times.
63921 else if(_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
16562
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24386 times.
✓ Branch 4 taken 22560 times.
✓ Branch 5 taken 1826 times.
24386 !_walkflag(x+7, y+15+1,1,STANDING_Z_STATE)&&
16563
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1826 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1826 times.
1826 !_walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
16564 {
16565
9/12
✓ Branch 0 taken 1723 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 1723 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1723 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1717 times.
✓ Branch 7 taken 6 times.
✓ Branch 8 taken 1717 times.
✓ Branch 9 taken 6 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1804 times.
1804 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
16566 1804 sprite::move((zfix)1,(zfix)0);
16567 1804 }
16568 else //if(shiftdir==-1)
16569 {
16570 37731 pushing=push+1;
16571
16572
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 37646 times.
37731 if(action!=swimming)
16573 {
16574 37646 }
16575 }
16576
16577 41527 z3step=2;
16578 41527 }
16579 else
16580 {
16581 31161 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16582
16583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31161 times.
31161 if(action!=swimming)
16584 {
16585 31161 }
16586
16587 31161 z3step=2;
16588 }
16589 72688 }
16590
16591 377470 return;
16592 }
16593 }
16594
16595
6/6
✓ Branch 0 taken 600618 times.
✓ Branch 1 taken 1638596 times.
✓ Branch 2 taken 583622 times.
✓ Branch 3 taken 16996 times.
✓ Branch 4 taken 582008 times.
✓ Branch 5 taken 1614 times.
2239214 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == left))
16596 {
16597
5/8
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 594342 times.
✓ Branch 2 taken 4511 times.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4662 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
599004 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM) && !toogam)
16598 {
16599 }
16600 else
16601 {
16602
3/4
✓ Branch 0 taken 592458 times.
✓ Branch 1 taken 6546 times.
✓ Branch 2 taken 592458 times.
✗ Branch 3 not taken.
599004 if(charging==0 && spins==0)
16603 {
16604 592458 dir=left;
16605 592458 }
16606
16607 599004 holddir=left;
16608
16609
4/4
✓ Branch 0 taken 75929 times.
✓ Branch 1 taken 523075 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 75926 times.
599004 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != down)
16610 {
16611 75926 shiftdir=up;
16612 75926 }
16613
4/4
✓ Branch 0 taken 61170 times.
✓ Branch 1 taken 461908 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 61158 times.
523078 else if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != up)
16614 {
16615 61158 shiftdir=down;
16616 61158 }
16617 else
16618 {
16619 461920 shiftdir=-1;
16620 }
16621
16622 //bool walkable;
16623 599004 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
16624
16625
2/2
✓ Branch 0 taken 254314 times.
✓ Branch 1 taken 344690 times.
599004 if(y.getInt()&7)
16626 344690 info = info || walkflag(x-z3step,y+16,1,left);
16627
16628 599004 execute(info);
16629
16630
2/2
✓ Branch 0 taken 73587 times.
✓ Branch 1 taken 525417 times.
599004 if(info.isUnwalkable())
16631 {
16632
2/2
✓ Branch 0 taken 72185 times.
✓ Branch 1 taken 1402 times.
73587 if(z3step==2)
16633 {
16634 72185 z3step=1;
16635 72185 info = walkflag(x-z3step,y+(bigHitbox?0:8),1,left)||walkflag(x-z3step,y+8,1,left);
16636
16637
2/2
✓ Branch 0 taken 44557 times.
✓ Branch 1 taken 27628 times.
72185 if(y.getInt()&7)
16638 44557 info = info || walkflag(x-z3step,y+16,1,left);
16639
16640 72185 execute(info);
16641
16642
2/2
✓ Branch 0 taken 67321 times.
✓ Branch 1 taken 4864 times.
72185 if(info.isUnwalkable())
16643 {
16644 67321 walkable = false;
16645 67321 }
16646 else
16647 {
16648 4864 walkable=true;
16649 }
16650 72185 }
16651 else
16652 {
16653 1402 walkable=false;
16654 }
16655 73587 }
16656 else
16657 {
16658 525417 walkable = true;
16659 }
16660
16661 599004 int32_t s=shiftdir;
16662
16663
10/14
✓ Branch 0 taken 4662 times.
✓ Branch 1 taken 594342 times.
✓ Branch 2 taken 4595 times.
✓ Branch 3 taken 67 times.
✓ Branch 4 taken 4662 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 69998 times.
✓ Branch 7 taken 529006 times.
✓ Branch 8 taken 69998 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 69998 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 69998 times.
✗ Branch 13 not taken.
599004 if((isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16664 {
16665 69998 shiftdir=-1;
16666 69998 }
16667 else
16668 {
16669
2/2
✓ Branch 0 taken 454669 times.
✓ Branch 1 taken 74337 times.
529006 if(s==up)
16670 {
16671 74337 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
16672 74337 execute(info);
16673
16674
2/2
✓ Branch 0 taken 8595 times.
✓ Branch 1 taken 65742 times.
74337 if(info.isUnwalkable())
16675 {
16676 8595 shiftdir=-1;
16677 8595 }
16678
2/2
✓ Branch 0 taken 9983 times.
✓ Branch 1 taken 55759 times.
65742 else if(walkable)
16679 {
16680 55759 info = walkflag(x-1,y+(bigHitbox?0:8)-1,1,up);
16681 55759 execute(info);
16682
16683
2/2
✓ Branch 0 taken 55678 times.
✓ Branch 1 taken 81 times.
55759 if(info.isUnwalkable())
16684 {
16685 81 shiftdir=-1;
16686 81 }
16687 55759 }
16688 74337 }
16689
2/2
✓ Branch 0 taken 394275 times.
✓ Branch 1 taken 60394 times.
454669 else if(s==down)
16690 {
16691 60394 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
16692 60394 execute(info);
16693
16694
2/2
✓ Branch 0 taken 9555 times.
✓ Branch 1 taken 50839 times.
60394 if(info.isUnwalkable())
16695 {
16696 9555 shiftdir=-1;
16697 9555 }
16698
2/2
✓ Branch 0 taken 7945 times.
✓ Branch 1 taken 42894 times.
50839 else if(walkable)
16699 {
16700 42894 info = walkflag(x-1,y+16,1,down);
16701 42894 execute(info);
16702
16703
2/2
✓ Branch 0 taken 42823 times.
✓ Branch 1 taken 71 times.
42894 if(info.isUnwalkable())
16704 {
16705 71 shiftdir=-1;
16706 71 }
16707 42894 }
16708 60394 }
16709 }
16710
16711 599004 moveOld2(left);
16712 599004 shiftdir=s;
16713
16714
2/2
✓ Branch 0 taken 530281 times.
✓ Branch 1 taken 68723 times.
599004 if(!walkable)
16715 {
16716
2/2
✓ Branch 0 taken 22576 times.
✓ Branch 1 taken 46147 times.
68723 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16717 {
16718 46147 int32_t v1=bigHitbox?0:8;
16719 46147 int32_t v2=bigHitbox?8:12;
16720
16721
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 46147 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46147 times.
✓ Branch 4 taken 38043 times.
✓ Branch 5 taken 8104 times.
✓ Branch 6 taken 1551 times.
✓ Branch 7 taken 44596 times.
54251 if(!_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
16722
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8104 times.
✓ Branch 4 taken 4024 times.
✓ Branch 5 taken 4080 times.
8104 !_walkflag(x-1,y+v2,1,STANDING_Z_STATE)&&
16723
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4080 times.
4080 _walkflag(x-1,y+15,1,STANDING_Z_STATE))
16724 {
16725
9/12
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 1422 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1422 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1418 times.
✓ Branch 7 taken 4 times.
✓ Branch 8 taken 1418 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 1551 times.
1551 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16726 1551 sprite::move((zfix)0,(zfix)-1);
16727 1551 }
16728
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 44596 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44596 times.
✓ Branch 4 taken 6553 times.
✓ Branch 5 taken 38043 times.
✓ Branch 6 taken 802 times.
✓ Branch 7 taken 43794 times.
82639 else if(_walkflag(x-1,y+v1, 1,STANDING_Z_STATE)&&
16729
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38043 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38043 times.
✓ Branch 4 taken 37241 times.
✓ Branch 5 taken 802 times.
38043 !_walkflag(x-1,y+v2-1,1,STANDING_Z_STATE)&&
16730
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 802 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 802 times.
802 !_walkflag(x-1,y+15, 1,STANDING_Z_STATE))
16731 {
16732
8/12
✓ Branch 0 taken 750 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 750 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 750 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 750 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 750 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 801 times.
802 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16733 801 sprite::move((zfix)0,(zfix)1);
16734 802 }
16735 else //if(shiftdir==-1)
16736 {
16737 43794 pushing=push+1;
16738
16739
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 43589 times.
43794 if(action!=swimming)
16740 {
16741 43589 }
16742 }
16743
16744 46147 z3step=2;
16745 46147 }
16746 else
16747 {
16748 22576 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16749
16750
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 22533 times.
22576 if(action!=swimming)
16751 {
16752 22533 }
16753
16754 22576 z3step=2;
16755 }
16756 68723 }
16757
16758 599004 return;
16759 }
16760 }
16761
16762
5/6
✓ Branch 0 taken 663276 times.
✓ Branch 1 taken 976934 times.
✓ Branch 2 taken 645546 times.
✓ Branch 3 taken 17730 times.
✓ Branch 4 taken 645546 times.
✗ Branch 5 not taken.
1640210 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == right))
16763 {
16764
5/8
✓ Branch 0 taken 4663 times.
✓ Branch 1 taken 658613 times.
✓ Branch 2 taken 4484 times.
✓ Branch 3 taken 179 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4663 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
663276 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM) && !toogam)
16765 {
16766 }
16767 else
16768 {
16769
3/4
✓ Branch 0 taken 655145 times.
✓ Branch 1 taken 8131 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 655145 times.
663276 if(charging==0 && spins==0)
16770 {
16771 655145 dir=right;
16772 655145 }
16773
16774 663276 holddir=right;
16775
16776
4/4
✓ Branch 0 taken 82864 times.
✓ Branch 1 taken 580412 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 82833 times.
663276 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != down)
16777 {
16778 82833 shiftdir=up;
16779 82833 }
16780
4/4
✓ Branch 0 taken 66527 times.
✓ Branch 1 taken 513916 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 66514 times.
580443 else if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != up)
16781 {
16782 66514 shiftdir=down;
16783 66514 }
16784 else
16785 {
16786 513929 shiftdir=-1;
16787 }
16788
16789 //bool walkable;
16790 663276 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
16791
16792
2/2
✓ Branch 0 taken 374316 times.
✓ Branch 1 taken 288960 times.
663276 if(y.getInt()&7)
16793 374316 info = info || walkflag(x+15+z3step,y+16,1,right);
16794
16795 663276 execute(info);
16796
16797
2/2
✓ Branch 0 taken 90569 times.
✓ Branch 1 taken 572707 times.
663276 if(info.isUnwalkable())
16798 {
16799
2/2
✓ Branch 0 taken 89087 times.
✓ Branch 1 taken 1482 times.
90569 if(z3step==2)
16800 {
16801 89087 z3step=1;
16802 89087 info = walkflag(x+15+z3step,y+(bigHitbox?0:8),1,right)||walkflag(x+15+z3step,y+8,1,right);
16803
16804
2/2
✓ Branch 0 taken 33839 times.
✓ Branch 1 taken 55248 times.
89087 if(y.getInt()&7)
16805 55248 info = info || walkflag(x+15+z3step,y+16,1,right);
16806
16807 89087 execute(info);
16808
16809
2/2
✓ Branch 0 taken 81577 times.
✓ Branch 1 taken 7510 times.
89087 if(info.isUnwalkable())
16810 {
16811 81577 walkable = false;
16812 81577 }
16813 else
16814 {
16815 7510 walkable=true;
16816 }
16817 89087 }
16818 else
16819 {
16820 1482 walkable=false;
16821 }
16822 90569 }
16823 else
16824 {
16825 572707 walkable = true;
16826 }
16827
16828 663276 int32_t s=shiftdir;
16829
16830
10/14
✓ Branch 0 taken 4663 times.
✓ Branch 1 taken 658613 times.
✓ Branch 2 taken 4647 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 4663 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 85857 times.
✓ Branch 7 taken 577419 times.
✓ Branch 8 taken 85857 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 85857 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 85857 times.
✗ Branch 13 not taken.
663276 if((isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM)) || (isSideViewHero() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking))
16831 {
16832 85857 shiftdir=-1;
16833 85857 }
16834 else
16835 {
16836
2/2
✓ Branch 0 taken 497041 times.
✓ Branch 1 taken 80378 times.
577419 if(s==up)
16837 {
16838 80378 info = walkflag(x,y+(bigHitbox?0:8)-1,2,up)||walkflag(x+15,y+(bigHitbox?0:8)-1,1,up);
16839 80378 execute(info);
16840
16841
2/2
✓ Branch 0 taken 10531 times.
✓ Branch 1 taken 69847 times.
80378 if(info.isUnwalkable())
16842 {
16843 10531 shiftdir=-1;
16844 10531 }
16845
2/2
✓ Branch 0 taken 11752 times.
✓ Branch 1 taken 58095 times.
69847 else if(walkable)
16846 {
16847 58095 info = walkflag(x+16,y+(bigHitbox?0:8)-1,1,up);
16848 58095 execute(info);
16849
16850
2/2
✓ Branch 0 taken 58004 times.
✓ Branch 1 taken 91 times.
58095 if(info.isUnwalkable())
16851 {
16852 91 shiftdir=-1;
16853 91 }
16854 58095 }
16855 80378 }
16856
2/2
✓ Branch 0 taken 431114 times.
✓ Branch 1 taken 65927 times.
497041 else if(s==down)
16857 {
16858 65927 info = walkflag(x,y+16,2,down)||walkflag(x+15,y+16,1,down);
16859 65927 execute(info);
16860
16861
2/2
✓ Branch 0 taken 11453 times.
✓ Branch 1 taken 54474 times.
65927 if(info.isUnwalkable())
16862 {
16863 11453 shiftdir=-1;
16864 11453 }
16865
2/2
✓ Branch 0 taken 9326 times.
✓ Branch 1 taken 45148 times.
54474 else if(walkable)
16866 {
16867 45148 info = walkflag(x+16,y+16,1,down);
16868 45148 execute(info);
16869
16870
2/2
✓ Branch 0 taken 45066 times.
✓ Branch 1 taken 82 times.
45148 if(info.isUnwalkable())
16871 {
16872 82 shiftdir=-1;
16873 82 }
16874 45148 }
16875 65927 }
16876 }
16877
16878 663276 moveOld2(right);
16879 663276 shiftdir=s;
16880
16881
2/2
✓ Branch 0 taken 580217 times.
✓ Branch 1 taken 83059 times.
663276 if(!walkable)
16882 {
16883
2/2
✓ Branch 0 taken 27386 times.
✓ Branch 1 taken 55673 times.
83059 if(shiftdir==-1) //Corner-shove; prevent being stuck on corners -V
16884 {
16885 55673 int32_t v1=bigHitbox?0:8;
16886 55673 int32_t v2=bigHitbox?8:12;
16887
16888 167019 info = !walkflag(x+16,y+v1,1,right)&&
16889 111346 !walkflag(x+16,y+v2,1,right)&&
16890 55673 walkflag(x+16,y+15,1,right);
16891
16892 //do NOT execute these
16893
2/2
✓ Branch 0 taken 1827 times.
✓ Branch 1 taken 53846 times.
55673 if(info.isUnwalkable())
16894 {
16895
10/12
✓ Branch 0 taken 1722 times.
✓ Branch 1 taken 105 times.
✓ Branch 2 taken 1722 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1722 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1721 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 1721 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 1 times.
✓ Branch 11 taken 1826 times.
1827 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
16896 1826 sprite::move((zfix)0,(zfix)-1);
16897 1827 }
16898 else
16899 {
16900 161538 info = walkflag(x+16,y+v1, 1,right)&&
16901 107692 !walkflag(x+16,y+v2-1,1,right)&&
16902 53846 !walkflag(x+16,y+15, 1,right);
16903
16904
2/2
✓ Branch 0 taken 939 times.
✓ Branch 1 taken 52907 times.
53846 if(info.isUnwalkable())
16905 {
16906
7/12
✓ Branch 0 taken 896 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 896 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 896 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 896 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 896 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 939 times.
939 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
16907 939 sprite::move((zfix)0,(zfix)1);
16908 939 }
16909 else //if(shiftdir==-1)
16910 {
16911 52907 pushing=push+1;
16912 52907 z3step=2;
16913
16914
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 52841 times.
52907 if(action!=swimming)
16915 {
16916 52841 }
16917 }
16918 }
16919
16920 55673 z3step=2;
16921 55673 }
16922 else
16923 {
16924 27386 pushing=push+1; // L: This makes solid damage combos and diagonal-triggered Armoses work.
16925
16926
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 27376 times.
27386 if(action!=swimming)
16927 {
16928 27376 }
16929
16930 27386 z3step=2;
16931 }
16932 83059 }
16933
16934 663276 return;
16935 }
16936 }
16937 }
16938
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1170246 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1170246 if(shield_forcedir > -1 && action != rafting)
16939 dir = shield_forcedir;
16940 1170246 int32_t wtry = iswaterex_z3(MAPCOMBO(x,y+15), -1, x,y+15, true, false);
16941 1170246 int32_t wtry8 = iswaterex_z3(MAPCOMBO(x+15,y+15), -1, x+15,y+15, true, false);
16942 1170246 int32_t wtrx = iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)), -1, x,y+(bigHitbox?0:8), true, false);
16943 1170246 int32_t wtrx8 = iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)), -1, x+15,y+(bigHitbox?0:8), true, false);
16944 1170246 int32_t wtrc = iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?8:12)), -1, x+8,y+(bigHitbox?8:12), true, false);
16945
16946
8/12
✓ Branch 0 taken 166630 times.
✓ Branch 1 taken 1003616 times.
✓ Branch 2 taken 166630 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 166630 times.
✓ Branch 6 taken 166630 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 163821 times.
✓ Branch 9 taken 2809 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 163821 times.
1170246 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))&&!(ladderx+laddery)&&z==0&&fakez==0)
16947 {
16948
8/12
✓ Branch 0 taken 571 times.
✓ Branch 1 taken 163250 times.
✓ Branch 2 taken 526 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 479 times.
✓ Branch 5 taken 47 times.
✓ Branch 6 taken 479 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 479 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
163821 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
16949 {
16950 //action=swimming;
16951
3/12
✓ Branch 0 taken 360 times.
✓ Branch 1 taken 119 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 360 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
479 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
16952 {
16953 hopclk = 0xFF;
16954 }
16955 479 }
16956 163821 }
16957
16958 1170246 return;
16959 } //endif (LTTPWALK)
16960 3779088 temp_step = hero_newstep;
16961 3779088 temp_x = x;
16962 3779088 temp_y = y;
16963
16964
7/8
✓ Branch 0 taken 2471883 times.
✓ Branch 1 taken 1307205 times.
✓ Branch 2 taken 2420353 times.
✓ Branch 3 taken 51530 times.
✓ Branch 4 taken 59406 times.
✓ Branch 5 taken 2412477 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 59406 times.
3779088 if(isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam)
16965 {
16966
2/4
✓ Branch 0 taken 59406 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 59406 times.
59406 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16967 goto LEFTRIGHT_NEWMOVE;
16968 59406 else goto LEFTRIGHT_OLDMOVE;
16969 }
16970
16971 // make it easier to get in left & right doors
16972
16973 //ignore ladder for this part. sigh sigh sigh -DD
16974 3719682 oldladderx = ladderx;
16975 3719682 oldladdery = laddery;
16976
2/4
✓ Branch 0 taken 3719682 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3719682 times.
3719682 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
16977 {
16978 if (isdungeon() && getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && (temp_x == 32 && temp_y == 80))
16979 {
16980 do
16981 {
16982 info = walkflag(temp_x,temp_y+(bigHitbox?0:8),1,left) ||
16983 walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left);
16984
16985 if(info.isUnwalkable())
16986 {
16987 if(temp_x != int32_t(temp_x))
16988 {
16989 temp_x = floor((double)temp_x);
16990 }
16991 else if(temp_step > 1)
16992 {
16993 if(temp_step != int32_t(temp_step)) //floor
16994 temp_step = floor((double)temp_step);
16995 else --temp_step;
16996 }
16997 else
16998 break;
16999 }
17000 }
17001 while(info.isUnwalkable());
17002
17003 if(!info.isUnwalkable())
17004 {
17005 x = temp_x;
17006 y = temp_y;
17007 hero_newstep = temp_step;
17008 //ONLY process the side-effects of the above walkflag if Hero will actually move
17009 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
17010 execute(info);
17011 moveOld2(left);
17012 return;
17013 }
17014 temp_x = x;
17015 temp_y = y;
17016 temp_step = hero_newstep;
17017 }
17018
17019 if (isdungeon() && getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && temp_x == 208 && temp_y == 80)
17020 {
17021 do
17022 {
17023 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
17024 walkflag(temp_x+15+temp_step,temp_y+8,1,right);
17025
17026 if(info.isUnwalkable())
17027 {
17028 if(temp_x != int32_t(temp_x))
17029 {
17030 temp_x = floor((double)temp_x);
17031 }
17032 else if(temp_step > 1)
17033 {
17034 if(temp_step != int32_t(temp_step)) //floor
17035 temp_step = floor((double)temp_step);
17036 else --temp_step;
17037 }
17038 else
17039 break;
17040 }
17041 }
17042 while(info.isUnwalkable());
17043
17044 if(!info.isUnwalkable())
17045 {
17046 x = temp_x;
17047 y = temp_y;
17048 hero_newstep = temp_step;
17049 execute(info);
17050 moveOld2(right);
17051 return;
17052 }
17053 temp_x = x;
17054 temp_y = y;
17055 temp_step = hero_newstep;
17056 }
17057
17058 ladderx = oldladderx;
17059 laddery = oldladdery;
17060
17061 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION))
17062 {
17063 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17064 {
17065 if(dir!=up && dir!=down)
17066 {
17067 if(xoff>2&&xoff<6)
17068 {
17069 moveOld2(dir);
17070 }
17071 else if(xoff>=6)
17072 {
17073 moveOld2(right);
17074 }
17075 else if(xoff>=1)
17076 {
17077 moveOld2(left);
17078 }
17079 }
17080 else
17081 {
17082 if(xoff>=4)
17083 {
17084 moveOld2(right);
17085 }
17086 else if(xoff<4)
17087 {
17088 moveOld2(left);
17089 }
17090 }
17091 }
17092 else
17093 {
17094 do
17095 {
17096 if(action==swimming || IsSideSwim() || action == swimhit)
17097 {
17098 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
17099
17100 if(_walkflag(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, 1,STANDING_Z_STATE) &&
17101 !(iswaterex_z3(MAPCOMBO(temp_x, temp_y+(bigHitbox?0:8)-temp_step), -1, temp_x, temp_y+(bigHitbox?0:8)-temp_step, true, false) &&
17102 iswaterex_z3(MAPCOMBO(temp_x+15, temp_y+(bigHitbox?0:8)-temp_step), -1, temp_x+15, temp_y+(bigHitbox?0:8)-temp_step, true, false)))
17103 info.setUnwalkable(true);
17104 }
17105 else
17106 {
17107 info = walkflag(temp_x,temp_y+(bigHitbox?0:8)-temp_step,2,up);
17108 if(x.getInt() & 7)
17109 info = info || walkflag(temp_x+16,temp_y+(bigHitbox?0:8)-temp_step,1,up);
17110 else
17111 info = info || walkflagMBlock(temp_x+8,temp_y+(bigHitbox?0:8)-temp_step);
17112 }
17113
17114 if(info.isUnwalkable())
17115 {
17116 if(temp_y != int32_t(temp_y))
17117 {
17118 temp_y = floor((double)temp_y);
17119 }
17120 else if(temp_step > 1)
17121 {
17122 if(temp_step != int32_t(temp_step)) //floor
17123 temp_step = floor((double)temp_step);
17124 else --temp_step;
17125 }
17126 else
17127 break;
17128 }
17129 }
17130 while(info.isUnwalkable());
17131
17132 execute(info);
17133
17134 if(!info.isUnwalkable())
17135 {
17136 x = temp_x;
17137 y = temp_y;
17138 hero_newstep = temp_step;
17139 moveOld2(up);
17140 return;
17141 }
17142
17143 if (!getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))
17144 {
17145 if(NO_GRIDLOCK)
17146 {
17147 x = x.getInt();
17148 y = y.getInt();
17149 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17150 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17151 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
17152 {
17153 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
17154 sprite::move((zfix)-1,(zfix)0);
17155 }
17156 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17157 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17158 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
17159 {
17160 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
17161 sprite::move((zfix)1,(zfix)0);
17162 }
17163 else
17164 {
17165 pushing=push+1;
17166 }
17167 }
17168 else pushing=push+1;
17169
17170 if(charging==0 && spins==0)
17171 {
17172 dir=up;
17173 }
17174
17175 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17176 {
17177 herostep();
17178 }
17179
17180 return;
17181 }
17182 else
17183 {
17184 goto LEFTRIGHT_NEWMOVE;
17185 }
17186 }
17187
17188 return;
17189 }
17190
17191 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
17192 {
17193 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17194 {
17195 if(dir!=up && dir!=down)
17196 {
17197 if(xoff>2&&xoff<6)
17198 {
17199 moveOld2(dir);
17200 }
17201 else if(xoff>=6)
17202 {
17203 moveOld2(right);
17204 }
17205 else if(xoff>=1)
17206 {
17207 moveOld2(left);
17208 }
17209 }
17210 else
17211 {
17212 if(xoff>=4)
17213 {
17214 moveOld2(right);
17215 }
17216 else if(xoff<4)
17217 {
17218 moveOld2(left);
17219 }
17220 }
17221 }
17222 else
17223 {
17224 do
17225 {
17226 if(action==swimming || IsSideSwim() || action == swimhit)
17227 {
17228 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
17229
17230 if(_walkflag(temp_x+15, temp_y+15+temp_step, 1,STANDING_Z_STATE) &&
17231 !(iswaterex_z3(MAPCOMBO(temp_x, temp_y+15+temp_step), -1, temp_x, temp_y+15+temp_step, true, false) &&
17232 iswaterex_z3(MAPCOMBO(temp_x+15, temp_y+15+temp_step), -1, temp_x+15, temp_y+15+temp_step, true, false)))
17233 info.setUnwalkable(true);
17234 }
17235 else
17236 {
17237 info=walkflag(temp_x,temp_y+15+temp_step,2,down);
17238 if(x.getInt() & 7)
17239 info = info || walkflag(temp_x+16,temp_y+15+temp_step,1,down);
17240 else
17241 info = info || walkflagMBlock(temp_x+8,temp_y+15+temp_step);
17242 }
17243
17244 if(info.isUnwalkable())
17245 {
17246 if(temp_y != int32_t(temp_y))
17247 {
17248 temp_y = floor((double)temp_y);
17249 }
17250 else if(temp_step > 1)
17251 {
17252 if(temp_step != int32_t(temp_step)) //floor
17253 temp_step = floor((double)temp_step);
17254 else --temp_step;
17255 }
17256 else
17257 break;
17258 }
17259 }
17260 while(info.isUnwalkable());
17261
17262 execute(info);
17263
17264 if(!info.isUnwalkable())
17265 {
17266 x = temp_x;
17267 y = temp_y;
17268 hero_newstep = temp_step;
17269 moveOld2(down);
17270 return;
17271 }
17272
17273 if (!getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))
17274 {
17275 if(NO_GRIDLOCK)
17276 {
17277 x = x.getInt();
17278 y = y.getInt();
17279 if(!_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
17280 !_walkflag(x+8, y+15+1,1,STANDING_Z_STATE)&&
17281 _walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
17282 {
17283 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
17284 sprite::move((zfix)-1,(zfix)0);
17285 }
17286 else if(_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
17287 !_walkflag(x+7, y+15+1,1,STANDING_Z_STATE)&&
17288 !_walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
17289 {
17290 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
17291 sprite::move((zfix)1,(zfix)0);
17292 }
17293 else
17294 {
17295 pushing=push+1;
17296 }
17297 }
17298 else pushing=push+1;
17299
17300 if(charging==0 && spins==0)
17301 {
17302 dir=down;
17303 }
17304
17305 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17306 {
17307 herostep();
17308 }
17309
17310 return;
17311 }
17312 else goto LEFTRIGHT_NEWMOVE;
17313 }
17314
17315 return;
17316 }
17317
17318 LEFTRIGHT_NEWMOVE:
17319 temp_x = x;
17320 temp_y = y;
17321 temp_step = hero_newstep;
17322 if(isdungeon() && (temp_y<=26 || temp_y>=134) && !get_qr(qr_FREEFORM) && !toogam)
17323 {
17324 return;
17325 }
17326
17327 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION))
17328 {
17329 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17330 {
17331 if(dir!=left && dir!=right)
17332 {
17333 if(yoff>2&&yoff<6)
17334 {
17335 moveOld2(dir);
17336 }
17337 else if(yoff>=6)
17338 {
17339 moveOld2(down);
17340 }
17341 else if(yoff>=1)
17342 {
17343 moveOld2(up);
17344 }
17345 }
17346 else
17347 {
17348 if(yoff>=4)
17349 {
17350 moveOld2(down);
17351 }
17352 else if(yoff<4)
17353 {
17354 moveOld2(up);
17355 }
17356 }
17357 }
17358 else
17359 {
17360 do
17361 {
17362 info = walkflag(temp_x-temp_step,temp_y+(bigHitbox?0:8),1,left) ||
17363 walkflag(temp_x-temp_step,temp_y+(isSideViewHero() ?0:8), 1,left);
17364
17365 if(y.getInt() & 7)
17366 info = info || walkflag(temp_x-temp_step,temp_y+16,1,left);
17367
17368 if(info.isUnwalkable())
17369 {
17370 if(temp_x != int32_t(temp_x))
17371 {
17372 temp_x = floor((double)temp_x);
17373 }
17374 else if(temp_step > 1)
17375 {
17376 if(temp_step != int32_t(temp_step)) //floor
17377 temp_step = floor((double)temp_step);
17378 else --temp_step;
17379 }
17380 else
17381 break;
17382 }
17383 }
17384 while(info.isUnwalkable());
17385
17386 execute(info);
17387
17388 if(!info.isUnwalkable())
17389 {
17390 x = temp_x;
17391 y = temp_y;
17392 hero_newstep = temp_step;
17393 moveOld2(left);
17394 return;
17395 }
17396
17397 if (!getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
17398 {
17399 if(NO_GRIDLOCK)
17400 {
17401 x = x.getInt();
17402 y = y.getInt();
17403 int32_t v1=bigHitbox?0:8;
17404 int32_t v2=bigHitbox?8:12;
17405
17406 if(!_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
17407 !_walkflag(x-1,y+v2,1,STANDING_Z_STATE)&&
17408 _walkflag(x-1,y+15,1,STANDING_Z_STATE))
17409 {
17410 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17411 sprite::move((zfix)0,(zfix)-1);
17412 }
17413 else if(_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
17414 !_walkflag(x-1,y+v2-1,1,STANDING_Z_STATE)&&
17415 !_walkflag(x-1,y+15, 1,STANDING_Z_STATE))
17416 {
17417 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17418 sprite::move((zfix)0,(zfix)1);
17419 }
17420 else
17421 {
17422 pushing=push+1;
17423 }
17424 }
17425 else pushing=push+1;
17426
17427 if(charging==0 && spins==0)
17428 {
17429 dir=left;
17430 }
17431
17432 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17433 {
17434 herostep();
17435 }
17436
17437 return;
17438 }
17439 }
17440
17441 return;
17442 }
17443
17444 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))
17445 {
17446 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17447 {
17448 if(dir!=left && dir!=right)
17449 {
17450 if(yoff>2&&yoff<6)
17451 {
17452 moveOld2(dir);
17453 }
17454 else if(yoff>=6)
17455 {
17456 moveOld2(down);
17457 }
17458 else if(yoff>=1)
17459 {
17460 moveOld2(up);
17461 }
17462 }
17463 else
17464 {
17465 if(yoff>=4)
17466 {
17467 moveOld2(down);
17468 }
17469 else if(yoff<4)
17470 {
17471 moveOld2(up);
17472 }
17473 }
17474 }
17475 else
17476 {
17477 do
17478 {
17479 info = walkflag(temp_x+15+temp_step,temp_y+(bigHitbox?0:8),1,right) ||
17480 walkflag(temp_x+15+temp_step,temp_y+(isSideViewHero() ?0:8),1,right);
17481
17482 if(y.getInt() & 7)
17483 info = info || walkflag(temp_x+15+temp_step,y+16,1,right);
17484
17485 if(info.isUnwalkable())
17486 {
17487 if(temp_x != int32_t(temp_x))
17488 {
17489 temp_x = floor((double)temp_x);
17490 }
17491 else if(temp_step > 1)
17492 {
17493 if(temp_step != int32_t(temp_step)) //floor
17494 temp_step = floor((double)temp_step);
17495 else --temp_step;
17496 }
17497 else
17498 break;
17499 }
17500 }
17501 while(info.isUnwalkable());
17502
17503 execute(info);
17504
17505 if(!info.isUnwalkable())
17506 {
17507 x = temp_x;
17508 y = temp_y;
17509 hero_newstep = temp_step;
17510 moveOld2(right);
17511 return;
17512 }
17513
17514 if (!getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
17515 {
17516 if(NO_GRIDLOCK)
17517 {
17518 x = x.getInt();
17519 y = y.getInt();
17520 int32_t v1=bigHitbox?0:8;
17521 int32_t v2=bigHitbox?8:12;
17522
17523 if(!_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
17524 !_walkflag(x+16,y+v2,1,STANDING_Z_STATE)&&
17525 _walkflag(x+16,y+15,1,STANDING_Z_STATE))
17526 {
17527 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17528 sprite::move((zfix)0,(zfix)-1);
17529 }
17530 else if(_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
17531 !_walkflag(x+16,y+v2-1,1,STANDING_Z_STATE)&&
17532 !_walkflag(x+16,y+15,1,STANDING_Z_STATE))
17533 {
17534 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17535 sprite::move((zfix)0,(zfix)1);
17536 }
17537 else
17538 {
17539 pushing=push+1;
17540 }
17541 }
17542 else pushing=push+1;
17543
17544 if(charging==0 && spins==0)
17545 {
17546 dir=right;
17547 }
17548
17549 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17550 {
17551 herostep();
17552 }
17553
17554 return;
17555 }
17556 }
17557 }
17558 }
17559 else
17560 {
17561 7439364 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
17562 3719682 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8,1,left);
17563
17564
10/10
✓ Branch 0 taken 2412477 times.
✓ Branch 1 taken 1307205 times.
✓ Branch 2 taken 304272 times.
✓ Branch 3 taken 2108205 times.
✓ Branch 4 taken 186363 times.
✓ Branch 5 taken 117909 times.
✓ Branch 6 taken 1889 times.
✓ Branch 7 taken 184474 times.
✓ Branch 8 taken 358 times.
✓ Branch 9 taken 1531 times.
3719682 if (isdungeon() && getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !info.isUnwalkable() && (x == 32 && y == 80))
17565 {
17566 //ONLY process the side-effects of the above walkflag if Hero will actually move
17567 //sigh sigh sigh... walkflag is a horrible mess :-/ -DD
17568 1531 execute(info);
17569 1531 moveOld2(left);
17570 1531 return;
17571 }
17572
17573 7436302 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right) ||
17574 3718151 walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+8,1,right);
17575
17576
10/10
✓ Branch 0 taken 2410946 times.
✓ Branch 1 taken 1307205 times.
✓ Branch 2 taken 337880 times.
✓ Branch 3 taken 2073066 times.
✓ Branch 4 taken 201211 times.
✓ Branch 5 taken 136669 times.
✓ Branch 6 taken 2221 times.
✓ Branch 7 taken 198990 times.
✓ Branch 8 taken 406 times.
✓ Branch 9 taken 1815 times.
3718151 if (isdungeon() && getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && !info.isUnwalkable() && x == 208 && y == 80)
17577 {
17578 1815 execute(info);
17579 1815 moveOld2(right);
17580 1815 return;
17581 }
17582
17583 3716336 ladderx = oldladderx;
17584 3716336 laddery = oldladdery;
17585
17586
2/2
✓ Branch 0 taken 416069 times.
✓ Branch 1 taken 3300267 times.
3716336 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION))
17587 {
17588
11/14
✓ Branch 0 taken 11759 times.
✓ Branch 1 taken 404310 times.
✓ Branch 2 taken 10988 times.
✓ Branch 3 taken 771 times.
✓ Branch 4 taken 8233 times.
✓ Branch 5 taken 2755 times.
✓ Branch 6 taken 8233 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8233 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8233 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✓ Branch 13 taken 8230 times.
416069 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17589 {
17590
4/4
✓ Branch 0 taken 8196 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 8195 times.
8230 if(dir!=up && dir!=down)
17591 {
17592
4/4
✓ Branch 0 taken 5693 times.
✓ Branch 1 taken 2502 times.
✓ Branch 2 taken 2427 times.
✓ Branch 3 taken 3266 times.
8195 if(xoff>2&&xoff<6)
17593 {
17594 3266 moveOld2(dir);
17595 3266 }
17596
2/2
✓ Branch 0 taken 2427 times.
✓ Branch 1 taken 2502 times.
4929 else if(xoff>=6)
17597 {
17598 2427 moveOld2(right);
17599 2427 }
17600
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2502 times.
2502 else if(xoff>=1)
17601 {
17602 2502 moveOld2(left);
17603 2502 }
17604 8195 }
17605 else
17606 {
17607
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 25 times.
35 if(xoff>=4)
17608 {
17609 10 moveOld2(right);
17610 10 }
17611
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 else if(xoff<4)
17612 {
17613 25 moveOld2(left);
17614 25 }
17615 }
17616 8230 }
17617 else
17618 {
17619
4/6
✓ Branch 0 taken 381459 times.
✓ Branch 1 taken 26380 times.
✓ Branch 2 taken 381459 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 381459 times.
407839 if(action==swimming || IsSideSwim() || action == swimhit)
17620 {
17621 26380 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
17622
17623
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 26380 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26380 times.
✓ Branch 4 taken 2023 times.
✓ Branch 5 taken 24357 times.
✓ Branch 6 taken 21669 times.
✓ Branch 7 taken 4711 times.
50737 if(_walkflag(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]), 1,STANDING_Z_STATE) &&
17624
2/2
✓ Branch 0 taken 4471 times.
✓ Branch 1 taken 19886 times.
44243 !(iswaterex_z3(MAPCOMBO(x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), -1, x, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])) &&
17625 19886 iswaterex_z3(MAPCOMBO(x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7])), -1, x+15, y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]))))
17626 4711 info.setUnwalkable(true);
17627 26380 }
17628 else
17629 {
17630 381459 info = walkflag(x,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),2,up);
17631
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 380682 times.
381459 if(x.getInt() & 7)
17632 777 info = info || walkflag(x+16,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]),1,up);
17633 else
17634 380682 info = info || walkflagMBlock(x+8,y+(bigHitbox?0:8)-int32_t(lsteps[y.getInt()&7]));
17635 }
17636
17637 407839 execute(info);
17638
17639
2/2
✓ Branch 0 taken 169874 times.
✓ Branch 1 taken 237965 times.
407839 if(!info.isUnwalkable())
17640 {
17641 237965 moveOld2(up);
17642 237965 return;
17643 }
17644
17645
4/4
✓ Branch 0 taken 151091 times.
✓ Branch 1 taken 18783 times.
✓ Branch 2 taken 18777 times.
✓ Branch 3 taken 132314 times.
169874 if (!getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))
17646 {
17647
2/4
✓ Branch 0 taken 132314 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 132314 times.
132314 if(NO_GRIDLOCK)
17648 {
17649 if(!_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17650 !_walkflag(x+8, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17651 _walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
17652 {
17653 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+(bigHitbox?0:8)-1))
17654 sprite::move((zfix)-1,(zfix)0);
17655 }
17656 else if(_walkflag(x,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17657 !_walkflag(x+7, y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
17658 !_walkflag(x+15,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
17659 {
17660 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+(bigHitbox?0:8)-1))
17661 sprite::move((zfix)1,(zfix)0);
17662 }
17663 else
17664 {
17665 pushing=push+1;
17666 }
17667 }
17668 132314 else pushing=push+1;
17669
17670
4/4
✓ Branch 0 taken 132131 times.
✓ Branch 1 taken 183 times.
✓ Branch 2 taken 132035 times.
✓ Branch 3 taken 96 times.
132314 if(charging==0 && spins==0)
17671 {
17672 132035 dir=up;
17673 132035 }
17674
17675
5/8
✓ Branch 0 taken 129287 times.
✓ Branch 1 taken 3027 times.
✓ Branch 2 taken 129287 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 129287 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 129287 times.
132314 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17676 {
17677 129287 herostep();
17678 129287 }
17679
17680 132314 return;
17681 }
17682 else
17683 {
17684 37560 goto LEFTRIGHT_OLDMOVE;
17685 }
17686 }
17687
17688 8230 return;
17689 }
17690
17691
2/2
✓ Branch 0 taken 370315 times.
✓ Branch 1 taken 2929952 times.
3300267 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
17692 {
17693
11/14
✓ Branch 0 taken 10694 times.
✓ Branch 1 taken 359621 times.
✓ Branch 2 taken 9975 times.
✓ Branch 3 taken 719 times.
✓ Branch 4 taken 6694 times.
✓ Branch 5 taken 3281 times.
✓ Branch 6 taken 6694 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6694 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6694 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✓ Branch 13 taken 6693 times.
370315 if(xoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17694 {
17695
3/4
✓ Branch 0 taken 6693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 6690 times.
6693 if(dir!=up && dir!=down)
17696 {
17697
4/4
✓ Branch 0 taken 4676 times.
✓ Branch 1 taken 2014 times.
✓ Branch 2 taken 2001 times.
✓ Branch 3 taken 2675 times.
6690 if(xoff>2&&xoff<6)
17698 {
17699 2675 moveOld2(dir);
17700 2675 }
17701
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 2014 times.
4015 else if(xoff>=6)
17702 {
17703 2001 moveOld2(right);
17704 2001 }
17705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2014 times.
2014 else if(xoff>=1)
17706 {
17707 2014 moveOld2(left);
17708 2014 }
17709 6690 }
17710 else
17711 {
17712
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(xoff>=4)
17713 {
17714 3 moveOld2(right);
17715 3 }
17716 else if(xoff<4)
17717 {
17718 moveOld2(left);
17719 }
17720 }
17721 6693 }
17722 else
17723 {
17724
4/6
✓ Branch 0 taken 340096 times.
✓ Branch 1 taken 23526 times.
✓ Branch 2 taken 340096 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 340096 times.
363622 if(action==swimming || IsSideSwim() || action == swimhit)
17725 {
17726 23526 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
17727
17728
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 23526 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23526 times.
✓ Branch 4 taken 2312 times.
✓ Branch 5 taken 21214 times.
✓ Branch 6 taken 17545 times.
✓ Branch 7 taken 5981 times.
44740 if(_walkflag(x+15, y+15+int32_t(lsteps[y.getInt()&7]), 1,STANDING_Z_STATE) &&
17729
2/2
✓ Branch 0 taken 5786 times.
✓ Branch 1 taken 15428 times.
36642 !(iswaterex_z3(MAPCOMBO(x, y+15+int32_t(lsteps[y.getInt()&7])), -1, x, y+15+int32_t(lsteps[y.getInt()&7])) &&
17730 15428 iswaterex_z3(MAPCOMBO(x+15, y+15+int32_t(lsteps[y.getInt()&7])), -1, x+15, y+15+int32_t(lsteps[y.getInt()&7]))))
17731 5981 info.setUnwalkable(true);
17732 23526 }
17733 else
17734 {
17735 340096 info=walkflag(x,y+15+int32_t(lsteps[y.getInt()&7]),2,down);
17736
2/2
✓ Branch 0 taken 724 times.
✓ Branch 1 taken 339372 times.
340096 if(x.getInt() & 7)
17737 724 info = (info || walkflag(x+16,y+15+int32_t(lsteps[y.getInt()&7]),1,down));
17738 else
17739 339372 info = (info || walkflagMBlock(x+8,y+15+int32_t(lsteps[y.getInt()&7])));
17740 }
17741
17742 363622 execute(info);
17743
17744
2/2
✓ Branch 0 taken 167095 times.
✓ Branch 1 taken 196527 times.
363622 if(!info.isUnwalkable())
17745 {
17746 196527 moveOld2(down);
17747 196527 return;
17748 }
17749
17750
4/4
✓ Branch 0 taken 146281 times.
✓ Branch 1 taken 20814 times.
✓ Branch 2 taken 20409 times.
✓ Branch 3 taken 125872 times.
167095 if (!getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))
17751 {
17752
2/4
✓ Branch 0 taken 125872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125872 times.
125872 if(NO_GRIDLOCK)
17753 {
17754 if(!_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
17755 !_walkflag(x+8, y+15+1,1,STANDING_Z_STATE)&&
17756 _walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
17757 {
17758 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),y+15+1))
17759 sprite::move((zfix)-1,(zfix)0);
17760 }
17761 else if(_walkflag(x, y+15+1,1,STANDING_Z_STATE)&&
17762 !_walkflag(x+7, y+15+1,1,STANDING_Z_STATE)&&
17763 !_walkflag(x+15,y+15+1,1,STANDING_Z_STATE))
17764 {
17765 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),y+15+1))
17766 sprite::move((zfix)1,(zfix)0);
17767 }
17768 else
17769 {
17770 pushing=push+1;
17771 }
17772 }
17773 125872 else pushing=push+1;
17774
17775
2/4
✓ Branch 0 taken 125872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125872 times.
✗ Branch 3 not taken.
125872 if(charging==0 && spins==0)
17776 {
17777 125872 dir=down;
17778 125872 }
17779
17780
5/8
✓ Branch 0 taken 123206 times.
✓ Branch 1 taken 2666 times.
✓ Branch 2 taken 123206 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 123206 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 123206 times.
125872 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17781 {
17782 123206 herostep();
17783 123206 }
17784
17785 125872 return;
17786 }
17787 41223 else goto LEFTRIGHT_OLDMOVE;
17788 }
17789
17790 6693 return;
17791 }
17792
17793 LEFTRIGHT_OLDMOVE:
17794
17795
7/8
✓ Branch 0 taken 2014946 times.
✓ Branch 1 taken 1053195 times.
✓ Branch 2 taken 1959592 times.
✓ Branch 3 taken 55354 times.
✓ Branch 4 taken 55639 times.
✓ Branch 5 taken 1959307 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 55639 times.
3068141 if(isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM) && !toogam)
17796 {
17797 55639 return;
17798 }
17799
17800
2/2
✓ Branch 0 taken 462695 times.
✓ Branch 1 taken 2549807 times.
3012502 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION))
17801 {
17802
11/14
✓ Branch 0 taken 8415 times.
✓ Branch 1 taken 454280 times.
✓ Branch 2 taken 7962 times.
✓ Branch 3 taken 453 times.
✓ Branch 4 taken 7343 times.
✓ Branch 5 taken 619 times.
✓ Branch 6 taken 7343 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7343 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7343 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✓ Branch 13 taken 7341 times.
462695 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17803 {
17804
3/4
✓ Branch 0 taken 7332 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7332 times.
7341 if(dir!=left && dir!=right)
17805 {
17806
4/4
✓ Branch 0 taken 5180 times.
✓ Branch 1 taken 2152 times.
✓ Branch 2 taken 2240 times.
✓ Branch 3 taken 2940 times.
7332 if(yoff>2&&yoff<6)
17807 {
17808 2940 moveOld2(dir);
17809 2940 }
17810
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 2152 times.
4392 else if(yoff>=6)
17811 {
17812 2240 moveOld2(down);
17813 2240 }
17814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2152 times.
2152 else if(yoff>=1)
17815 {
17816 2152 moveOld2(up);
17817 2152 }
17818 7332 }
17819 else
17820 {
17821
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 3 times.
9 if(yoff>=4)
17822 {
17823 6 moveOld2(down);
17824 6 }
17825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 else if(yoff<4)
17826 {
17827 3 moveOld2(up);
17828 3 }
17829 }
17830 7341 }
17831 else
17832 {
17833 910708 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,left) ||
17834 455354 walkflag(x-int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero() ?0:8), 1,left);
17835
17836 455354 execute(info);
17837
17838
2/2
✓ Branch 0 taken 164089 times.
✓ Branch 1 taken 291265 times.
455354 if(!info.isUnwalkable())
17839 {
17840 291265 moveOld2(left);
17841 291265 return;
17842 }
17843
17844
4/4
✓ Branch 0 taken 156076 times.
✓ Branch 1 taken 8013 times.
✓ Branch 2 taken 8593 times.
✓ Branch 3 taken 147483 times.
164089 if (!getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
17845 {
17846
2/4
✓ Branch 0 taken 147483 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147483 times.
147483 if(NO_GRIDLOCK)
17847 {
17848 int32_t v1=bigHitbox?0:8;
17849 int32_t v2=bigHitbox?8:12;
17850
17851 if(!_walkflag(x-1,y+v1,1,STANDING_Z_STATE)&&
17852 !_walkflag(x-1,y+v2,1,STANDING_Z_STATE)&&
17853 _walkflag(x-1,y+15,1,STANDING_Z_STATE))
17854 {
17855 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17856 sprite::move((zfix)0,(zfix)-1);
17857 }
17858 else if(_walkflag(x-1,y+v1, 1,STANDING_Z_STATE)&&
17859 !_walkflag(x-1,y+v2-1,1,STANDING_Z_STATE)&&
17860 !_walkflag(x-1,y+15, 1,STANDING_Z_STATE))
17861 {
17862 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x-1,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17863 sprite::move((zfix)0,(zfix)1);
17864 }
17865 else
17866 {
17867 pushing=push+1;
17868 }
17869 }
17870 147483 else pushing=push+1;
17871
17872
3/4
✓ Branch 0 taken 147477 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147477 times.
147483 if(charging==0 && spins==0)
17873 {
17874 147477 dir=left;
17875 147477 }
17876
17877
5/8
✓ Branch 0 taken 143688 times.
✓ Branch 1 taken 3795 times.
✓ Branch 2 taken 143688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 143688 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 143688 times.
147483 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17878 {
17879 143688 herostep();
17880 143688 }
17881
17882 147483 return;
17883 }
17884 }
17885
17886 23947 return;
17887 }
17888
17889
2/2
✓ Branch 0 taken 2047980 times.
✓ Branch 1 taken 501827 times.
2549807 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))
17890 {
17891
10/14
✓ Branch 0 taken 8229 times.
✓ Branch 1 taken 493598 times.
✓ Branch 2 taken 7620 times.
✓ Branch 3 taken 609 times.
✓ Branch 4 taken 7422 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 7422 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7422 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7422 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 7422 times.
501827 if(yoff && !is_on_conveyor && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && jumping<1)
17892 {
17893
4/4
✓ Branch 0 taken 7419 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 7410 times.
7422 if(dir!=left && dir!=right)
17894 {
17895
4/4
✓ Branch 0 taken 5268 times.
✓ Branch 1 taken 2142 times.
✓ Branch 2 taken 2234 times.
✓ Branch 3 taken 3034 times.
7410 if(yoff>2&&yoff<6)
17896 {
17897 3034 moveOld2(dir);
17898 3034 }
17899
2/2
✓ Branch 0 taken 2234 times.
✓ Branch 1 taken 2142 times.
4376 else if(yoff>=6)
17900 {
17901 2234 moveOld2(down);
17902 2234 }
17903
1/2
✓ Branch 0 taken 2142 times.
✗ Branch 1 not taken.
2142 else if(yoff>=1)
17904 {
17905 2142 moveOld2(up);
17906 2142 }
17907 7410 }
17908 else
17909 {
17910
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
12 if(yoff>=4)
17911 {
17912 6 moveOld2(down);
17913 6 }
17914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 else if(yoff<4)
17915 {
17916 6 moveOld2(up);
17917 6 }
17918 }
17919 7422 }
17920 else
17921 {
17922 988810 info = walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(bigHitbox?0:8),1,right)
17923 494405 || walkflag(x+15+int32_t(lsteps[x.getInt()&7]),y+(isSideViewHero()?0:8),1,right);
17924
17925 494405 execute(info);
17926
17927
2/2
✓ Branch 0 taken 181175 times.
✓ Branch 1 taken 313230 times.
494405 if(!info.isUnwalkable())
17928 {
17929 313230 moveOld2(right);
17930 313230 return;
17931 }
17932
17933
4/4
✓ Branch 0 taken 174556 times.
✓ Branch 1 taken 6619 times.
✓ Branch 2 taken 8011 times.
✓ Branch 3 taken 166545 times.
181175 if (!getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
17934 {
17935
2/4
✓ Branch 0 taken 166545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 166545 times.
166545 if(NO_GRIDLOCK)
17936 {
17937 int32_t v1=bigHitbox?0:8;
17938 int32_t v2=bigHitbox?8:12;
17939
17940 if(!_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
17941 !_walkflag(x+16,y+v2,1,STANDING_Z_STATE)&&
17942 _walkflag(x+16,y+15,1,STANDING_Z_STATE))
17943 {
17944 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11)))
17945 sprite::move((zfix)0,(zfix)-1);
17946 }
17947 else if(_walkflag(x+16,y+v1,1,STANDING_Z_STATE)&&
17948 !_walkflag(x+16,y+v2-1,1,STANDING_Z_STATE)&&
17949 !_walkflag(x+16,y+15,1,STANDING_Z_STATE))
17950 {
17951 if(hclk || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS)) || !checkdamagecombos(x+16,y+v1+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
17952 sprite::move((zfix)0,(zfix)1);
17953 }
17954 else
17955 {
17956 pushing=push+1;
17957 }
17958 }
17959 166545 else pushing=push+1;
17960
17961
2/4
✓ Branch 0 taken 166545 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 166545 times.
166545 if(charging==0 && spins==0)
17962 {
17963 166545 dir=right;
17964 166545 }
17965
17966
5/8
✓ Branch 0 taken 164951 times.
✓ Branch 1 taken 1594 times.
✓ Branch 2 taken 164951 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 164951 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 164951 times.
166545 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
17967 {
17968 164951 herostep();
17969 164951 }
17970
17971 166545 return;
17972 }
17973 }
17974 22052 }
17975 }
17976 13292581 }
17977
17978 4474617 bool HeroClass::scr_walkflag(zfix_round zdx,zfix_round zdy,int d2,bool kb, int* canladder)
17979 {
17980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4474617 times.
4474617 if(toogam) return false;
17981 4474617 int dx = zdx.getRound(), dy = zdy.getRound();
17982
17983 4474617 bool solid = false;
17984
17985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4474617 times.
4474617 if(!is_autowalking())
17986 {
17987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4474617 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4474617 if(blockpath && dy<80) //Blocked top parts of rooms
17988 return true;
17989
17990
4/4
✓ Branch 0 taken 30097 times.
✓ Branch 1 taken 4444520 times.
✓ Branch 2 taken 18818 times.
✓ Branch 3 taken 11279 times.
4474617 if(mblock2.active() && mblock2.hit(dx,dy,0,1,1,1))
17991 11279 return true;
17992 //collide_object handled in scr_canmove
17993
17994
4/6
✓ Branch 0 taken 683926 times.
✓ Branch 1 taken 3779412 times.
✓ Branch 2 taken 683926 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4463338 times.
4487117 if(isdungeon() && cur_screen<128 && dy<40
17995
5/10
✓ Branch 0 taken 23779 times.
✓ Branch 1 taken 660147 times.
✓ Branch 2 taken 13692 times.
✓ Branch 3 taken 10087 times.
✓ Branch 4 taken 13692 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
683926 && ((x<=112||x>=128) || _walkflag(120,24,2,STANDING_Z_STATE))
17996
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
23779 && !get_qr(qr_FREEFORM))
17997 return true; //Old NES dungeon stuff
17998
17999
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4463338 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4463338 times.
4463338 solid = _walkflag(zdx,zdy,1,STANDING_Z_STATE);
18000
18001
4/6
✓ Branch 0 taken 683926 times.
✓ Branch 1 taken 3779412 times.
✓ Branch 2 taken 683926 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 683926 times.
✗ Branch 5 not taken.
4463338 if(isdungeon() && cur_screen<128 && !get_qr(qr_FREEFORM))
18002 {
18003 if(dx>=112&&dx<120&&dy<40&&dy>=32)
18004 solid=true;
18005
18006 if(dx>=136&&dx<144&&dy<40&&dy>=32)
18007 solid=true;
18008 }
18009 4463338 }
18010
18011
3/4
✓ Branch 0 taken 4426559 times.
✓ Branch 1 taken 36779 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4426559 times.
4463338 if(action==swimming || IsSideSwim())
18012 {
18013
2/2
✓ Branch 0 taken 13463 times.
✓ Branch 1 taken 23316 times.
36779 if(!solid)
18014 {
18015 23316 int ls = 22;
18016
1/6
✓ Branch 0 taken 23316 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
23316 if((get_qr(qr_DROWN) && isSwimming()) || (!diagonalMovement) || get_qr(qr_NO_HOPPING))
18017 23316 ls = 1;
18018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23316 times.
23316 if(landswim < ls)
18019 {
18020
2/4
✓ Branch 0 taken 23316 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23316 times.
23316 if(dx<0||dy<0);
18021
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 23296 times.
23316 else if(dx>=256);
18022
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 23278 times.
23296 else if(dy>=176);
18023
2/4
✓ Branch 0 taken 23278 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23278 times.
23278 else if(get_qr(qr_DROWN) && !ilswim);
18024 else if(iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
18025 solid = false;
18026 else
18027 solid = true;
18028 23316 }
18029 23316 }
18030 else
18031 {
18032 13463 int32_t wtrx = iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy);
18033
18034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13463 times.
13463 if(wtrx)
18035 solid = false;
18036 }
18037 36779 }
18038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4426559 times.
4426559 else if(ladderx+laddery) // ladder is being used
18039 {
18040 if (canladder)
18041 {
18042 *canladder = 0;
18043 }
18044 int32_t lx = zfix(dx);
18045 int32_t ly = zfix(dy);
18046
18047 if(ladderdir<=down) //vertical ladder
18048 {
18049 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
18050 {
18051 bool temp = false;
18052
18053 if(!(abs(lx-(ladderx+8))<=8))
18054 temp = true;
18055
18056 if(!temp)
18057 {
18058 solid = false;
18059 }
18060 else if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
18061 {
18062 solid = true;
18063 }
18064 }
18065 }
18066 else //horizontal ladder
18067 {
18068 if(abs(lx-(ladderx+8))<=8)
18069 {
18070 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
18071 {
18072 solid = false;
18073 }
18074 else if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
18075 {
18076 solid = true;
18077 }
18078 else if((abs(ly-laddery+8)<=8) && d2<=down)
18079 {
18080 solid = false;
18081 }
18082 }
18083 }
18084 }
18085
5/6
✓ Branch 0 taken 2179566 times.
✓ Branch 1 taken 2246993 times.
✓ Branch 2 taken 2175959 times.
✓ Branch 3 taken 3607 times.
✓ Branch 4 taken 2175959 times.
✗ Branch 5 not taken.
4426559 else if(solid || isSideViewHero() || get_qr(qr_DROWN))
18086 {
18087 // see if it's a good spot for the ladder or for swimming
18088
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4426559 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4426559 times.
4426559 bool unwalkablex = _walkflag(zdx,zdy,1,STANDING_Z_STATE); //will be used later for the ladder -DD
18089
18090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4426559 times.
4426559 if(get_qr(qr_DROWN))
18091 {
18092 // Drowning changes the following attributes:
18093 // * Dangerous water is also walkable, so ignore the previous
18094 // definitions of unwalkablex.
18095 // * Instead, prevent the ladder from being used in the
18096 // one frame where Hero has landed on water before drowning.
18097 4426559 unwalkablex = !iswaterex_z3(MAPCOMBO(x+4,y+11), -1, x+4,y+11);
18098 4426559 }
18099
18100 // check if he can swim
18101
4/6
✓ Branch 0 taken 431507 times.
✓ Branch 1 taken 3995052 times.
✓ Branch 2 taken 431507 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 431507 times.
4426559 if(current_item(itype_flippers) && z==0 && fakez==0)
18102 {
18103 431507 int32_t wtrx = iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy);
18104
5/6
✓ Branch 0 taken 431333 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 893 times.
✓ Branch 3 taken 430440 times.
✓ Branch 4 taken 893 times.
✗ Branch 5 not taken.
431507 if (current_item(itype_flippers) >= combobuf[wtrx].attribytes[0] && (!(combobuf[wtrx].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))) //Don't swim if the water's required level is too high! -Dimi
18105 {
18106 //ladder ignores water combos that are now walkable thanks to flippers -DD
18107
2/2
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 426751 times.
431333 unwalkablex = unwalkablex && (!wtrx);
18108
18109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431333 times.
431333 if(landswim >= 22)
18110 {
18111 solid = false;
18112 }
18113
2/2
✓ Branch 0 taken 426996 times.
✓ Branch 1 taken 4337 times.
431333 else if(wtrx)
18114 {
18115
2/2
✓ Branch 0 taken 998 times.
✓ Branch 1 taken 3339 times.
4337 if(dir==d2)
18116 {
18117 3339 ladderx = 0;
18118 3339 laddery = 0;
18119 3339 }
18120 4337 }
18121 431333 }
18122 431507 }
18123
18124 // check if he can use the ladder
18125 // "Allow Ladder Anywhere" is toggled by fLADDER
18126
1/2
✓ Branch 0 taken 4426559 times.
✗ Branch 1 not taken.
4426559 if(can_deploy_ladder())
18127 // laddersetup
18128 {
18129 // Check if there's water to use the ladder over
18130 bool wtrx = (iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy) != 0);
18131 int32_t ldrid = current_item_id(itype_ladder);
18132 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&item_flag1);
18133
18134 if(wtrx)
18135 {
18136 if(isSideViewHero())
18137 {
18138 wtrx = !_walkflag(zdx, zdy+8, 1,STANDING_Z_STATE) && !_walkflag(dx, dy, 1,STANDING_Z_STATE) && dir!=down;
18139 }
18140 // * walk on half-water using the ladder instead of using flippers.
18141 // * otherwise, walk on ladder(+hookshot) combos.
18142 else if((isstepable(MAPCOMBO(dx, dy)) || wtrx==true))
18143 {
18144 if(!get_qr(qr_OLD_210_WATER) && current_item(itype_flippers))
18145 {
18146 //if Hero could swim on a tile instead of using the ladder,
18147 //refuse to use the ladder to step over that tile. -DD
18148 wtrx = isstepable(MAPCOMBO(dx, dy)) && unwalkablex;
18149 }
18150 }
18151 }
18152 else
18153 {
18154 // No water; check other things
18155
18156 //Check pits
18157 if(ladderpits)
18158 {
18159 int32_t pit_cmb = getpitfall(dx,dy);
18160 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
18161 }
18162 if(!ladderpits || (!wtrx || isSideViewHero())) //If no pit, check ladder combos
18163 {
18164 int32_t combo=combobuf[MAPCOMBO(dx, dy)].type;
18165 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
18166 }
18167 }
18168
18169 for (int32_t i = 1; i <= 2; ++i)
18170 {
18171 if (get_scr_layer_valid(current_screen, i))
18172 {
18173 if (get_qr(qr_OLD_BRIDGE_COMBOS))
18174 {
18175 if (combobuf[MAPCOMBO2(i-1,dx,dy)].type == cBRIDGE && !_walkflag_layer(dx,dy)) wtrx = false;
18176 }
18177 else
18178 {
18179 if (combobuf[MAPCOMBO2(i-1,dx,dy)].type == cBRIDGE && _effectflag_layer(dx,dy)) wtrx = false;
18180 }
18181 }
18182 }
18183 bool walkwater = (get_qr(qr_DROWN) && !iswaterex_z3(MAPCOMBO(dx,dy), -1, dx,dy));
18184
18185 if (!wtrx && solid)
18186 {
18187 if (canladder)
18188 {
18189 *canladder = 0;
18190 }
18191 }
18192
18193 if(d2==dir)
18194 {
18195 int32_t c = walkwater ? 0:8;
18196 int32_t b = walkwater ? 8:0;
18197
18198 if(d2>=left)
18199 {
18200 if (wtrx)
18201 {
18202 //If the difference between dy and y is small enough
18203 //this is apparently a really crappy corner shove check?
18204 if((replay_version_check(26)) || (abs((dy)-(int32_t(y+c)))<=(b)))
18205 {
18206 // Don't activate the ladder if it would be entirely
18207 // over water and Hero has the flippers. This isn't
18208 // a good way to do this, but it's too risky
18209 // to make big changes to this stuff.
18210 bool deployLadder=true;
18211 int32_t lx=dx&0xF0;
18212 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex_z3(MAPCOMBO(lx+8, y+8), -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
18213 {
18214 if(iswaterex_z3(MAPCOMBO(lx, y), -1, lx, y) &&
18215 iswaterex_z3(MAPCOMBO(lx+15, y), -1, lx+15, y) &&
18216 iswaterex_z3(MAPCOMBO(lx, y+15), -1, lx, y+15) &&
18217 iswaterex_z3(MAPCOMBO(lx+15, y+15), -1, lx+15, y+15))
18218 deployLadder=false;
18219 }
18220 if(deployLadder)
18221 {
18222 if (replay_version_check(26))
18223 {
18224 if (canladder)
18225 {
18226 if (*canladder == -1) *canladder = 1;
18227 }
18228 }
18229 else
18230 {
18231 ladderx = dx&0xF0;
18232 laddery = y;
18233 ladderdir = left;
18234 ladderstart = d2;
18235 solid = laddery!=y.getInt();
18236 }
18237 }
18238 }
18239 }
18240 }
18241 else if(d2<=down)
18242 {
18243 if (wtrx)
18244 {
18245 //Unsure if this actually needs a replay check but better safe than sorry?
18246 if (replay_version_check(26))
18247 {
18248 if (canladder)
18249 {
18250 if (*canladder == -1) *canladder = 1;
18251 }
18252 }
18253 // If the difference between dx and x is small enough
18254 if(!replay_version_check(26) && (abs((dx)-(int32_t(x+c)))<=(b)))
18255 {
18256 ladderx = x;
18257 laddery = dy&0xF0;
18258 ladderdir = up;
18259 ladderstart = d2;
18260 solid = ladderx!=x.getInt();
18261 }
18262 }
18263 }
18264 }
18265 }
18266 4426559 }
18267
18268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4463338 times.
4463338 if (replay_version_check(26))
18269 {
18270
2/2
✓ Branch 0 taken 3241429 times.
✓ Branch 1 taken 1221909 times.
4463338 if (canladder)
18271 {
18272
3/4
✓ Branch 0 taken 1355349 times.
✓ Branch 1 taken 1886080 times.
✓ Branch 2 taken 1355349 times.
✗ Branch 3 not taken.
3241429 if (solid && *canladder == 1) *canladder = 2;
18273 3241429 }
18274 4463338 }
18275
18276
2/2
✓ Branch 0 taken 2202882 times.
✓ Branch 1 taken 2260456 times.
4463338 return solid && !is_autowalking();
18277 4474617 }
18278
18279 1484257 bool HeroClass::scr_canmove(zfix dx, zfix dy, bool kb, bool ign_sv, int* canladder)
18280 {
18281
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1484257 times.
1484257 if(toogam) return true;
18282
3/4
✓ Branch 0 taken 718698 times.
✓ Branch 1 taken 765559 times.
✓ Branch 2 taken 718698 times.
✗ Branch 3 not taken.
1484257 if(!(dx || dy)) return true;
18283 1484257 zfix bx = x, by = y+(bigHitbox?0:8); //left/top
18284 1484257 zfix rx = x+15.9999_zf, ry = y+15.9999_zf; //right/bottom
18285 1484257 zfix wid = 16, hei = bigHitbox ? 16 : 8;
18286
7/14
✓ Branch 0 taken 1415468 times.
✓ Branch 1 taken 68789 times.
✓ Branch 2 taken 336765 times.
✓ Branch 3 taken 1078703 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 336635 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 130 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
1484257 if(!ign_sv && dy < 0 && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking)
18287 return false;
18288
18289 1484257 bool nosolid = true;
18290
18291 1484257 bool ret = true;
18292
18293
3/4
✓ Branch 0 taken 765559 times.
✓ Branch 1 taken 718698 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 765559 times.
1484257 if(dx && !dy)
18294 {
18295
2/2
✓ Branch 0 taken 355607 times.
✓ Branch 1 taken 409952 times.
765559 if(dx < 0)
18296 {
18297 355607 zfix mx = bx+dx;
18298
2/2
✓ Branch 0 taken 355607 times.
✓ Branch 1 taken 237608 times.
593215 for(zfix ty = 0; by+ty < ry; ty += 8)
18299 {
18300
2/2
✓ Branch 0 taken 211021 times.
✓ Branch 1 taken 144586 times.
355607 if(scr_walkflag(mx, by+ty, left, kb, canladder))
18301 {
18302
2/2
✓ Branch 0 taken 26587 times.
✓ Branch 1 taken 117999 times.
144586 if (canladder) ret = false;
18303 else
18304 {
18305 117999 return false;
18306 }
18307 26587 }
18308 237608 }
18309
2/2
✓ Branch 0 taken 48847 times.
✓ Branch 1 taken 188761 times.
237608 if(scr_walkflag(mx, ry, left, kb, canladder))
18310 48847 return false;
18311
2/2
✓ Branch 0 taken 184717 times.
✓ Branch 1 taken 4044 times.
188761 if (!ret) return false;
18312
2/4
✓ Branch 0 taken 184717 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 184717 times.
✗ Branch 3 not taken.
184717 if(nosolid && collide_object(bx+dx,by,-dx,hei,this))
18313 return false;
18314 184717 }
18315 else
18316 {
18317 409952 zfix mx = rx+dx;
18318 409952 int lx = mx-hit_width+1;
18319
2/2
✓ Branch 0 taken 409952 times.
✓ Branch 1 taken 275659 times.
685611 for(zfix ty = 0; by+ty < ry; ty += 8)
18320 {
18321
2/2
✓ Branch 0 taken 239222 times.
✓ Branch 1 taken 170730 times.
409952 if(scr_walkflag(mx, by+ty, right, kb, canladder))
18322 {
18323
2/2
✓ Branch 0 taken 36437 times.
✓ Branch 1 taken 134293 times.
170730 if (canladder) ret = false;
18324 else
18325 {
18326 134293 return false;
18327 }
18328 36437 }
18329 275659 }
18330
2/2
✓ Branch 0 taken 73418 times.
✓ Branch 1 taken 202241 times.
275659 if(scr_walkflag(mx, ry, right, kb, canladder))
18331 73418 return false;
18332
2/2
✓ Branch 0 taken 194787 times.
✓ Branch 1 taken 7454 times.
202241 if (!ret) return false;
18333
2/4
✓ Branch 0 taken 194787 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 194787 times.
✗ Branch 3 not taken.
194787 if(nosolid && collide_object(bx+wid,by,dx,hei,this))
18334 return false;
18335 }
18336 379504 }
18337
2/4
✓ Branch 0 taken 718698 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 718698 times.
718698 else if(dy && !dx)
18338 {
18339
2/2
✓ Branch 0 taken 345979 times.
✓ Branch 1 taken 372719 times.
718698 if(dy < 0)
18340 {
18341 345979 zfix my = by+dy;
18342
2/2
✓ Branch 0 taken 599676 times.
✓ Branch 1 taken 234232 times.
833908 for(zfix tx = 0; bx+tx < rx; tx += 8)
18343 {
18344
2/2
✓ Branch 0 taken 368598 times.
✓ Branch 1 taken 231078 times.
599676 if(scr_walkflag(bx+tx, my, up, kb, canladder))
18345 {
18346
2/2
✓ Branch 0 taken 119331 times.
✓ Branch 1 taken 111747 times.
231078 if (canladder) ret = false;
18347 else
18348 {
18349 111747 return false;
18350 }
18351 119331 }
18352 487929 }
18353
2/2
✓ Branch 0 taken 76733 times.
✓ Branch 1 taken 157499 times.
234232 if(scr_walkflag(rx, my, up, kb, canladder))
18354 76733 return false;
18355
2/2
✓ Branch 0 taken 141713 times.
✓ Branch 1 taken 15786 times.
157499 if (!ret) return false;
18356
2/4
✓ Branch 0 taken 141713 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 141713 times.
✗ Branch 3 not taken.
141713 if(nosolid && collide_object(bx,by+dy,wid,-dy,this))
18357 return false;
18358 141713 }
18359 else
18360 {
18361 372719 zfix my = ry+dy;
18362 372719 int ly = my-hit_height+1;
18363
2/2
✓ Branch 0 taken 613203 times.
✓ Branch 1 taken 212533 times.
825736 for(zfix tx = 0; bx+tx < rx; tx += 8)
18364 {
18365
2/2
✓ Branch 0 taken 403846 times.
✓ Branch 1 taken 209357 times.
613203 if(scr_walkflag(bx+tx, my, down, kb, canladder))
18366 {
18367
2/2
✓ Branch 0 taken 49171 times.
✓ Branch 1 taken 160186 times.
209357 if (canladder) ret = false;
18368 else
18369 {
18370 160186 return false;
18371 }
18372 49171 }
18373 453017 }
18374
2/2
✓ Branch 0 taken 59778 times.
✓ Branch 1 taken 152755 times.
212533 if(scr_walkflag(rx, my, down, kb, canladder))
18375 59778 return false;
18376
2/2
✓ Branch 0 taken 145940 times.
✓ Branch 1 taken 6815 times.
152755 if (!ret) return false;
18377
2/4
✓ Branch 0 taken 145940 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 145940 times.
145940 if(nosolid && collide_object(bx,by+hei,wid,dy,this))
18378 return false;
18379 }
18380 287653 }
18381 else //! Untested, and currently unused.
18382 {
18383 return scr_canmove(dx, 0, kb, ign_sv) && scr_canmove(dy, 0, kb, ign_sv);
18384 }
18385 667157 return ret;
18386 1484257 }
18387 444360 bool handle_movestate(std::function<bool()> proc)
18388 {
18389 444360 zfix ox = Hero.x, oy = Hero.y;
18390 444360 auto oladderx = Hero.ladderx;
18391 444360 auto oladdery = Hero.laddery;
18392 444360 auto oladderdir = Hero.ladderdir;
18393 444360 auto oladderstart = Hero.ladderstart;
18394
18395 444360 bool ret = proc();
18396
18397 444360 Hero.x = ox;
18398 444360 Hero.y = oy;
18399 444360 Hero.ladderx = oladderx;
18400 444360 Hero.laddery = oladdery;
18401 444360 Hero.ladderdir = oladderdir;
18402 444360 Hero.ladderstart = oladderstart;
18403
18404 444360 return ret;
18405 }
18406
18407 70 zfix handle_movestate_zfix(std::function<zfix()> proc)
18408 {
18409 70 zfix ox = Hero.x, oy = Hero.y;
18410 70 auto oladderx = Hero.ladderx;
18411 70 auto oladdery = Hero.laddery;
18412 70 auto oladderdir = Hero.ladderdir;
18413 70 auto oladderstart = Hero.ladderstart;
18414
18415 70 zfix ret = proc();
18416
18417 70 Hero.x = ox;
18418 70 Hero.y = oy;
18419 70 Hero.ladderx = oladderx;
18420 70 Hero.laddery = oladdery;
18421 70 Hero.ladderdir = oladderdir;
18422 70 Hero.ladderstart = oladderstart;
18423
18424 70 return ret;
18425 }
18426
18427 52726 optional<zfix> HeroClass::get_solid_coord(zfix tx, zfix ty, byte dir, byte mdir, bool kb, zfix earlyterm, bool doladder)
18428 {
18429 52726 zfix tmp;
18430
4/5
✓ Branch 0 taken 4305 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9249 times.
✓ Branch 3 taken 20746 times.
✓ Branch 4 taken 18426 times.
52726 switch(dir)
18431 {
18432 default:
18433 case up:
18434
2/4
✓ Branch 0 taken 4305 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4305 times.
✗ Branch 3 not taken.
78542 tmp = binary_search_zfix(ty, earlyterm, [&](zfix ty, zfix& retval)
18435 {
18436 74237 int laddercheck = -1;
18437
2/2
✓ Branch 0 taken 36594 times.
✓ Branch 1 taken 37643 times.
74237 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18438 {
18439 36594 retval = ty;
18440 36594 return BSEARCH_CONTINUE_UP;
18441 }
18442
2/4
✓ Branch 0 taken 37643 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37643 times.
37643 else if(doladder && laddercheck > 0)
18443 {
18444 retval = ty;
18445 return BSEARCH_CONTINUE_UP;
18446 }
18447 37643 else return BSEARCH_CONTINUE_DOWN;
18448
1/2
✓ Branch 0 taken 4305 times.
✗ Branch 1 not taken.
78542 }, -999);
18449
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 3900 times.
4305 if(tmp > -999)
18450 3900 tmp -= 15.9999_zf;
18451 4305 break;
18452 case down:
18453
2/4
✓ Branch 0 taken 9249 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9249 times.
✗ Branch 3 not taken.
171198 tmp = binary_search_zfix(ty, earlyterm, [&](zfix ty, zfix& retval)
18454 {
18455 161949 int laddercheck = -1;
18456
2/2
✓ Branch 0 taken 68594 times.
✓ Branch 1 taken 93355 times.
161949 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18457 {
18458 68594 retval = ty;
18459 68594 return BSEARCH_CONTINUE_DOWN;
18460 }
18461
2/4
✓ Branch 0 taken 93355 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93355 times.
93355 else if(doladder && laddercheck > 0)
18462 {
18463 retval = ty;
18464 return BSEARCH_CONTINUE_DOWN;
18465 }
18466 93355 else return BSEARCH_CONTINUE_UP;
18467
1/2
✓ Branch 0 taken 9249 times.
✗ Branch 1 not taken.
171198 }, -999);
18468
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 8921 times.
9249 if(tmp > -999)
18469 8921 tmp -= (bigHitbox?0:8);
18470 9249 break;
18471 case left:
18472
2/4
✓ Branch 0 taken 20746 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20746 times.
✗ Branch 3 not taken.
388122 tmp = binary_search_zfix(tx, earlyterm, [&](zfix tx, zfix& retval)
18473 {
18474 367376 int laddercheck = -1;
18475
2/2
✓ Branch 0 taken 49393 times.
✓ Branch 1 taken 317983 times.
367376 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18476 {
18477 49393 retval = tx;
18478 49393 return BSEARCH_CONTINUE_UP;
18479 }
18480
2/4
✓ Branch 0 taken 317983 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 317983 times.
317983 else if(doladder && laddercheck > 0)
18481 {
18482 retval = tx;
18483 return BSEARCH_CONTINUE_UP;
18484 }
18485 317983 else return BSEARCH_CONTINUE_DOWN;
18486
1/2
✓ Branch 0 taken 20746 times.
✗ Branch 1 not taken.
388122 }, -999);
18487
2/2
✓ Branch 0 taken 15276 times.
✓ Branch 1 taken 5470 times.
20746 if(tmp > -999)
18488 5470 tmp -= 15.9999_zf;
18489 20746 break;
18490 case right:
18491
2/4
✓ Branch 0 taken 18426 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18426 times.
✗ Branch 3 not taken.
346191 tmp = binary_search_zfix(tx, earlyterm, [&](zfix tx, zfix& retval)
18492 {
18493 327765 int laddercheck = -1;
18494
2/2
✓ Branch 0 taken 38349 times.
✓ Branch 1 taken 289416 times.
327765 if(!scr_walkflag(tx,ty,mdir,kb, &laddercheck))
18495 {
18496 38349 retval = tx;
18497 38349 return BSEARCH_CONTINUE_DOWN;
18498 }
18499
2/4
✓ Branch 0 taken 289416 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 289416 times.
289416 else if(doladder && laddercheck > 0)
18500 {
18501 retval = tx;
18502 return BSEARCH_CONTINUE_DOWN;
18503 }
18504 289416 else return BSEARCH_CONTINUE_UP;
18505
1/2
✓ Branch 0 taken 18426 times.
✗ Branch 1 not taken.
346191 }, -999);
18506 18426 break;
18507 }
18508
2/2
✓ Branch 0 taken 29922 times.
✓ Branch 1 taken 22804 times.
52726 if(tmp > -999)
18509 {
18510 22804 zfix tx2(x), ty2(y);
18511 22804 zfix dx, dy;
18512
4/5
✓ Branch 0 taken 3900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5470 times.
✓ Branch 3 taken 4513 times.
✓ Branch 4 taken 8921 times.
22804 switch(dir)
18513 {
18514 case left:
18515 5470 tx2 = tmp;
18516 5470 break;
18517 case right:
18518 4513 tx2 = tmp;
18519 4513 break;
18520 default:
18521 case up:
18522 3900 ty2 = tmp;
18523 3900 break;
18524 case down:
18525 8921 ty2 = tmp;
18526 8921 break;
18527 }
18528
4/5
✓ Branch 0 taken 4894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4027 times.
✓ Branch 3 taken 8794 times.
✓ Branch 4 taken 5089 times.
22804 switch(mdir)
18529 {
18530 case left:
18531 4027 dx = -0.0001_zf;
18532 4027 break;
18533 case right:
18534 8794 dx = 0.0001_zf;
18535 8794 break;
18536 default:
18537 case up:
18538 4894 dy = -0.0001_zf;
18539 4894 break;
18540 case down:
18541 5089 dy = 0.0001_zf;
18542 5089 break;
18543 }
18544 22804 zfix oldx(x), oldy(y);
18545 22804 x = tx2;
18546 22804 y = ty2;
18547 22804 int laddercheck = -1;
18548 22804 bool valid = scr_canmove(dx, dy, kb, true, &laddercheck);
18549
1/2
✓ Branch 0 taken 22804 times.
✗ Branch 1 not taken.
22804 if (laddercheck > 0) valid = true;
18550 22804 x = oldx;
18551 22804 y = oldy;
18552
2/2
✓ Branch 0 taken 22754 times.
✓ Branch 1 taken 50 times.
22804 if(valid)
18553 22754 return tmp;
18554 50 }
18555 29972 return std::nullopt;
18556 52726 }
18557
18558 727656 bool HeroClass::movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove, bool earlyret)
18559 {
18560 727656 bool ret = true;
18561 727656 int ladderstuff = -1;
18562
8/10
✓ Branch 0 taken 703995 times.
✓ Branch 1 taken 23661 times.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 703234 times.
✓ Branch 4 taken 559 times.
✓ Branch 5 taken 202 times.
✓ Branch 6 taken 559 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 559 times.
727656 bool sv = !ign_sv && sideview_mode() && !getOnSideviewLadder() && action != sideswimming && action != sideswimhit && action != sideswimattacking;
18563
2/2
✓ Branch 0 taken 727097 times.
✓ Branch 1 taken 559 times.
727656 if(sv)
18564 559 dy = 0;
18565
4/4
✓ Branch 0 taken 426002 times.
✓ Branch 1 taken 301654 times.
✓ Branch 2 taken 358718 times.
✓ Branch 3 taken 67284 times.
727656 if(dx && dy)
18566 67284 shove = false;
18567 727656 bool checkladder = dy < 0;
18568
18569 727656 const int scl = 2;
18570
4/4
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 727712 times.
✓ Branch 2 taken 230 times.
✓ Branch 3 taken 727656 times.
727886 while(abs(dx) > scl || abs(dy) > scl)
18571 {
18572
2/2
✓ Branch 0 taken 174 times.
✓ Branch 1 taken 56 times.
230 if(abs(dx) > abs(dy))
18573 {
18574 174 int32_t tdx = dx.sign() * scl;
18575
2/2
✓ Branch 0 taken 173 times.
✓ Branch 1 taken 1 times.
174 if(movexy(tdx, 0, kb, ign_sv, shove, earlyret))
18576 173 dx -= tdx;
18577 else
18578 {
18579
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(earlyret) return false;
18580 1 dx = tdx;
18581 1 ret = false;
18582 }
18583 174 }
18584 else
18585 {
18586 56 int32_t tdy = dy.sign() * scl;
18587
1/2
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
56 if(movexy(0, tdy, kb, ign_sv, shove, earlyret))
18588 56 dy -= tdy;
18589 else
18590 {
18591 if(earlyret) return false;
18592 dy = tdy;
18593 ret = false;
18594 }
18595 }
18596 }
18597
18598
10/12
✓ Branch 0 taken 283156 times.
✓ Branch 1 taken 444500 times.
✓ Branch 2 taken 29604 times.
✓ Branch 3 taken 253552 times.
✓ Branch 4 taken 29604 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 632 times.
✓ Branch 7 taken 28972 times.
✓ Branch 8 taken 27732 times.
✓ Branch 9 taken 1240 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 27732 times.
727656 bool skipdmg = earlyret || get_qr(qr_LENIENT_SOLID_DAMAGE) || get_qr(qr_NOSOLIDDAMAGECOMBOS) || hclk || ((z>0||fakez>0) && !(hero_scr->flags2&fAIRCOMBOS));
18599
2/2
✓ Branch 0 taken 301654 times.
✓ Branch 1 taken 426002 times.
727656 if(dx)
18600 {
18601
2/2
✓ Branch 0 taken 355678 times.
✓ Branch 1 taken 70324 times.
426002 if(scr_canmove(dx, 0, kb, ign_sv, &ladderstuff))
18602 {
18603
1/2
✓ Branch 0 taken 355678 times.
✗ Branch 1 not taken.
355678 if (ladderstuff == 1)
18604 {
18605 zfix tx = (dx < 0 ? (x+dx) : (x+8+dx));
18606 zfix tx2 = (dx < 0 ? 15 : 0);
18607 zfix tx3 = (dx < 0 ? -8 : 8);
18608 ladderx = TRUNCATE_HALF_TILE(tx.getInt());
18609 laddery = y.getTrunc();
18610 if (((iswaterex_z3(MAPCOMBO(ladderx+tx2,y+9), -1, ladderx+tx2,y+9) != 0) || getpitfall(ladderx+tx2,y+9))
18611 && ((iswaterex_z3(MAPCOMBO(ladderx+tx2,y+15), -1, ladderx+tx2,y+15) != 0) || getpitfall(ladderx+tx2,y+15)))
18612 {
18613 ladderdir = left;
18614 ladderstart = dir;
18615 }
18616 else if (((iswaterex_z3(MAPCOMBO(ladderx+tx2+tx3,y+9), -1, ladderx+tx2+tx3,y+9) != 0) || getpitfall(ladderx+tx2+tx3,y+9))
18617 && ((iswaterex_z3(MAPCOMBO(ladderx+tx2+tx3,y+15), -1, ladderx+tx2+tx3,y+15) != 0) || getpitfall(ladderx+tx2+tx3,y+15)))
18618 {
18619 ladderx = TRUNCATE_HALF_TILE(tx.getInt()+tx3.getInt());
18620 ladderdir = left;
18621 ladderstart = dir;
18622 }
18623 else
18624 {
18625 ladderx = 0;
18626 laddery = 0;
18627 }
18628 }
18629
1/2
✓ Branch 0 taken 355678 times.
✗ Branch 1 not taken.
355678 if (ladderstuff > 0) ladderstuff = 0;
18630 355678 x += dx;
18631 355678 }
18632 else
18633 {
18634 70324 bool stopped = true;
18635 70324 bool shoved = false;
18636
2/2
✓ Branch 0 taken 11024 times.
✓ Branch 1 taken 59300 times.
70324 if(shove)
18637 {
18638
2/2
✓ Branch 0 taken 24461 times.
✓ Branch 1 taken 34839 times.
59300 zfix tx = (dx < 0 ? (x-4) : (x+20));
18639 59300 int v=bigHitbox?0:8;
18640 59300 zfix ly = y+v;
18641 59300 zfix ry = y+15.9999_zf;
18642 59300 zfix ly2 = y+v+6;
18643 59300 zfix ry2 = y+9.9999_zf;
18644 59300 auto mdir = GET_XDIR(dx);
18645 59300 int laddershove = -1;
18646 59300 int ladderhit = 0;
18647 59300 bool onladder = (ladderx + laddery);
18648 59300 bool hit_top = scr_walkflag(tx,ly,mdir,false, &laddershove);
18649
1/2
✓ Branch 0 taken 59300 times.
✗ Branch 1 not taken.
59300 if (laddershove > 0)
18650 {
18651 hit_top = false;
18652 ladderhit += 1;
18653 }
18654 59300 laddershove = -1;
18655 59300 bool hit_bottom = scr_walkflag(tx,ry,mdir,false, &laddershove);
18656
1/2
✓ Branch 0 taken 59300 times.
✗ Branch 1 not taken.
59300 if (laddershove > 0)
18657 {
18658 hit_bottom = false;
18659 ladderhit += 2;
18660 }
18661 59300 laddershove = -1;
18662 59300 bool hit_top2 = scr_walkflag(tx,ly2,mdir,false);
18663 59300 bool hit_bottom2 = scr_walkflag(tx,ry2,mdir,false);
18664
3/4
✓ Branch 0 taken 4422 times.
✓ Branch 1 taken 54878 times.
✓ Branch 2 taken 4422 times.
✗ Branch 3 not taken.
59300 if (!hit_top && ladderhit == 2)
18665 {
18666 hit_bottom = true;
18667 }
18668
3/4
✓ Branch 0 taken 9366 times.
✓ Branch 1 taken 49934 times.
✓ Branch 2 taken 9366 times.
✗ Branch 3 not taken.
59300 if (!hit_bottom && ladderhit == 1)
18669 {
18670 hit_top = true;
18671 }
18672
2/2
✓ Branch 0 taken 45746 times.
✓ Branch 1 taken 13554 times.
59300 if(hit_top!=hit_bottom)
18673 {
18674
2/2
✓ Branch 0 taken 4305 times.
✓ Branch 1 taken 9249 times.
13554 if(hit_bottom) //shove up
18675 {
18676
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4305 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4305 if (onladder && (ladderdir == left || ladderdir == right) && !hit_bottom2)
18677 {
18678 y -= 1_zf;
18679 shoved = true;
18680 }
18681
5/6
✓ Branch 0 taken 4275 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4305 times.
4305 else if(skipdmg || !checkdamagecombos(tx,get_qr(qr_SENSITIVE_SOLID_DAMAGE)?int32_t(y+15):(v+bigHitbox?11:4)))
18682 {
18683
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 3896 times.
4305 if(optional<zfix> ty = get_solid_coord(tx,ry,up,mdir,false,ry-shove_offset, (ladderhit != 2)))
18684 {
18685
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 3206 times.
3896 zfix dy = zc_max(-1_zf,*ty-y);
18686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3896 times.
3896 if((shoved = dy))
18687 3896 movexy(0, dy, kb, true, false, false);
18688 3896 }
18689 4305 }
18690 4305 }
18691 else //shove down
18692 {
18693
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9249 if (onladder && (ladderdir == left || ladderdir == right) && !hit_top2)
18694 {
18695 y += 1_zf;
18696 shoved = true;
18697 }
18698
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9242 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
9249 else if(skipdmg || !checkdamagecombos(tx,v+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4)))
18699 {
18700
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 8921 times.
9249 if(optional<zfix> ty = get_solid_coord(tx,ly,down,mdir,false,ly+shove_offset, (ladderhit != 1)))
18701 {
18702
2/2
✓ Branch 0 taken 8287 times.
✓ Branch 1 taken 634 times.
8921 zfix dy = zc_min(1_zf,*ty-y);
18703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8921 times.
8921 if((shoved = dy))
18704 8921 movexy(0, dy, kb, true, false, false);
18705 8921 }
18706 9249 }
18707 }
18708
18709
4/4
✓ Branch 0 taken 12817 times.
✓ Branch 1 taken 737 times.
✓ Branch 2 taken 11378 times.
✓ Branch 3 taken 1439 times.
13554 if(shoved && scr_canmove(dx, 0, kb, ign_sv))
18710 {
18711 1439 x += dx;
18712 1439 stopped = false;
18713 1439 }
18714 13554 }
18715 59300 }
18716
2/2
✓ Branch 0 taken 1439 times.
✓ Branch 1 taken 68885 times.
70324 if(stopped)
18717 {
18718
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 68885 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
68885 if (ladderstuff > 0 && !shoved)
18719 {
18720 zfix tx = (dx < 0 ? (x-12) : (x+20));
18721 ladderx = TRUNCATE_HALF_TILE(tx.getInt());
18722 laddery = y.getTrunc();
18723 ladderdir = left;
18724 ladderstart = dir;
18725 x += dx;
18726 ladderstuff = 0;
18727 }
18728
2/2
✓ Branch 0 taken 48997 times.
✓ Branch 1 taken 19888 times.
68885 else if(earlyret)
18729 {
18730 48997 ret = false;
18731 48997 }
18732 else
18733 {
18734 19888 ret = false;
18735 19888 int xsign = dx.sign();
18736
2/2
✓ Branch 0 taken 1860 times.
✓ Branch 1 taken 18028 times.
19888 if(abs(dx) > 1)
18737 {
18738
2/2
✓ Branch 0 taken 469 times.
✓ Branch 1 taken 18028 times.
18497 while(scr_canmove(xsign, 0, kb, ign_sv))
18739 {
18740 469 x += xsign;
18741 469 dx -= xsign;
18742 }
18743 18028 }
18744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19888 times.
19888 if(dx)
18745 {
18746 19888 dx.doDecBound(0,-9999, 0,9999);
18747
3/6
✓ Branch 0 taken 19888 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19888 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19888 times.
✗ Branch 5 not taken.
315296 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
18748
2/2
✓ Branch 0 taken 9087 times.
✓ Branch 1 taken 286321 times.
295408 if(scr_canmove(val, 0, kb, ign_sv))
18749 {
18750 9087 retval = val;
18751 9087 return BSEARCH_CONTINUE_AWAY0;
18752 }
18753 286321 else return BSEARCH_CONTINUE_TOWARD0;
18754 295408 });
18755 19888 x += dx;
18756 19888 }
18757 }
18758 68885 }
18759 }
18760 426002 }
18761 727656 ladderstuff = -1;
18762
2/2
✓ Branch 0 taken 359680 times.
✓ Branch 1 taken 367976 times.
727656 if(dy)
18763 {
18764
2/2
✓ Branch 0 taken 264096 times.
✓ Branch 1 taken 103880 times.
367976 if(scr_canmove(0, dy, kb, ign_sv, &ladderstuff))
18765 {
18766
1/2
✓ Branch 0 taken 264096 times.
✗ Branch 1 not taken.
264096 if (ladderstuff == 1)
18767 {
18768 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)+dy) : (y+8+dy));
18769 zfix ty2 = (dy < 0 ? 15 : 0);
18770 zfix ty3 = (dy < 0 ? -8 : 8);
18771
18772 ladderx = x.getTrunc();
18773 laddery = TRUNCATE_HALF_TILE(ty.getInt());
18774 if (((iswaterex_z3(MAPCOMBO(x+4,laddery+ty2), -1, x+4,laddery+ty2) != 0) || getpitfall(x+4,laddery+ty2))
18775 && ((iswaterex_z3(MAPCOMBO(x+11,laddery+ty2), -1, x+11,laddery+ty2) != 0) || getpitfall(x+11,laddery+ty2)))
18776 {
18777 ladderdir = up;
18778 ladderstart = dir;
18779 }
18780 else if (((iswaterex_z3(MAPCOMBO(x+4,laddery+ty2+ty3), -1, x+4,laddery+ty2+ty3) != 0) || getpitfall(x+4,laddery+ty2+ty3))
18781 && ((iswaterex_z3(MAPCOMBO(x+11,laddery+ty2+ty3), -1, x+11,laddery+ty2+ty3) != 0) || getpitfall(x+11,laddery+ty2+ty3)))
18782 {
18783 laddery = TRUNCATE_HALF_TILE(ty.getInt() + ty3.getInt());
18784 ladderdir = up;
18785 ladderstart = dir;
18786 }
18787 else
18788 {
18789 ladderx = 0;
18790 laddery = 0;
18791 }
18792 }
18793
1/2
✓ Branch 0 taken 264096 times.
✗ Branch 1 not taken.
264096 if (ladderstuff > 0) ladderstuff = 0;
18794 264096 y += dy;
18795 264096 }
18796 else
18797 {
18798 103880 bool stopped = true;
18799 103880 bool shoved = false;
18800
2/2
✓ Branch 0 taken 11975 times.
✓ Branch 1 taken 91905 times.
103880 if(shove)
18801 {
18802
2/2
✓ Branch 0 taken 66553 times.
✓ Branch 1 taken 25352 times.
91905 zfix ty = (dy < 0 ? (y+(bigHitbox?0:8)-4) : (y+20));
18803 91905 zfix lx = x;
18804 91905 zfix rx = x+15.9999_zf;
18805 91905 zfix lx2 = x+6;
18806 91905 zfix rx2 = x+9.9999_zf;
18807 91905 auto mdir = GET_YDIR(dy);
18808 91905 int laddershove = -1;
18809 91905 int ladderhit = 0;
18810 91905 bool onladder = (ladderx + laddery);
18811 91905 bool hit_left = scr_walkflag(lx,ty,mdir,false, &laddershove);
18812
1/2
✓ Branch 0 taken 91905 times.
✗ Branch 1 not taken.
91905 if (laddershove > 0)
18813 {
18814 hit_left = false;
18815 ladderhit += 1;
18816 }
18817 91905 laddershove = -1;
18818 91905 bool hit_right = scr_walkflag(rx,ty,mdir,false, &laddershove);
18819
1/2
✓ Branch 0 taken 91905 times.
✗ Branch 1 not taken.
91905 if (laddershove > 0)
18820 {
18821 hit_right = false;
18822 ladderhit += 2;
18823 }
18824 91905 bool hit_left2 = scr_walkflag(lx2,ty,mdir,false);
18825 91905 bool hit_right2 = scr_walkflag(rx2,ty,mdir,false);
18826 91905 laddershove = -1;
18827
3/4
✓ Branch 0 taken 20920 times.
✓ Branch 1 taken 70985 times.
✓ Branch 2 taken 20920 times.
✗ Branch 3 not taken.
91905 if (!hit_left && ladderhit == 2)
18828 {
18829 hit_right = true;
18830 }
18831
3/4
✓ Branch 0 taken 18600 times.
✓ Branch 1 taken 73305 times.
✓ Branch 2 taken 18600 times.
✗ Branch 3 not taken.
91905 if (!hit_right && ladderhit == 1)
18832 {
18833 hit_left = true;
18834 }
18835
2/2
✓ Branch 0 taken 52733 times.
✓ Branch 1 taken 39172 times.
91905 if(hit_left!=hit_right)
18836 {
18837
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 18426 times.
39172 if(hit_right) //shove left
18838 {
18839
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 20746 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
20746 if (onladder && ladderdir <= down && !hit_right2)
18840 {
18841 x -= 1_zf;
18842 shoved = true;
18843 }
18844
3/4
✓ Branch 0 taken 20734 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20746 times.
20746 else if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?15:11),ty))
18845 {
18846
2/2
✓ Branch 0 taken 15276 times.
✓ Branch 1 taken 5470 times.
20746 if(optional<zfix> tx = get_solid_coord(rx,ty,left,mdir,false,rx-shove_offset, (ladderhit != 2)))
18847 {
18848
2/2
✓ Branch 0 taken 4400 times.
✓ Branch 1 taken 1070 times.
5470 zfix dx = zc_max(-1_zf,*tx-x);
18849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5470 times.
5470 if((shoved = dx))
18850 5470 movexy(dx, 0, kb, true, false, false);
18851 5470 }
18852 20746 }
18853 20746 }
18854 else //shove right
18855 {
18856
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18426 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18426 if (onladder && ladderdir <= down && !hit_left2)
18857 {
18858 x += 1_zf;
18859 shoved = true;
18860 }
18861
3/4
✓ Branch 0 taken 18396 times.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18426 times.
18426 else if(skipdmg || !checkdamagecombos(x+(get_qr(qr_SENSITIVE_SOLID_DAMAGE)?0:4),ty))
18862 {
18863
2/2
✓ Branch 0 taken 13959 times.
✓ Branch 1 taken 4467 times.
18426 if(optional<zfix> tx = get_solid_coord(lx,ty,right,mdir,false,lx+shove_offset, (ladderhit != 1)))
18864 {
18865
2/2
✓ Branch 0 taken 1675 times.
✓ Branch 1 taken 2792 times.
4467 zfix dx = zc_min(1_zf,*tx-x);
18866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4467 times.
4467 if((shoved = dx))
18867 4467 movexy(dx, 0, kb, true, false, false);
18868 4467 }
18869 18426 }
18870 }
18871
18872
4/4
✓ Branch 0 taken 9937 times.
✓ Branch 1 taken 29235 times.
✓ Branch 2 taken 6924 times.
✓ Branch 3 taken 3013 times.
39172 if(shoved && scr_canmove(0, dy, kb, ign_sv))
18873 {
18874 3013 y += dy;
18875 3013 stopped = false;
18876 3013 }
18877 39172 }
18878 91905 }
18879
2/2
✓ Branch 0 taken 3013 times.
✓ Branch 1 taken 100867 times.
103880 if(stopped)
18880 {
18881
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 100867 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
100867 if (ladderstuff > 0 && !shoved)
18882 {
18883 zfix ty = (dy < 0 ? (y-(bigHitbox?12:4)) : (y+20));
18884 ladderx = x.getTrunc();
18885 laddery = TRUNCATE_HALF_TILE(ty.getInt());
18886 ladderdir = up;
18887 ladderstart = dir;
18888 y += dy;
18889 ladderstuff = 0;
18890 }
18891 else
18892 {
18893
2/2
✓ Branch 0 taken 79867 times.
✓ Branch 1 taken 21000 times.
100867 if(earlyret) return false;
18894 21000 ret = false;
18895 21000 int ysign = dy.sign();
18896
2/2
✓ Branch 0 taken 2645 times.
✓ Branch 1 taken 18355 times.
21000 if(abs(dy) > 1)
18897 {
18898
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 18355 times.
18699 while(scr_canmove(0, ysign, kb, ign_sv))
18899 {
18900 344 y += ysign;
18901 344 dy -= ysign;
18902 }
18903 18355 }
18904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21000 times.
21000 if(dy)
18905 {
18906 21000 dy.doDecBound(0,-9999, 0,9999);
18907
3/6
✓ Branch 0 taken 21000 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 21000 times.
✗ Branch 5 not taken.
333047 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
18908
2/2
✓ Branch 0 taken 10207 times.
✓ Branch 1 taken 301840 times.
312047 if(scr_canmove(0, val, kb, ign_sv))
18909 {
18910 10207 retval = val;
18911 10207 return BSEARCH_CONTINUE_AWAY0;
18912 }
18913 301840 else return BSEARCH_CONTINUE_TOWARD0;
18914 312047 });
18915 21000 y += dy;
18916 21000 }
18917 }
18918 21000 }
18919 }
18920 288109 }
18921
18922
2/2
✓ Branch 0 taken 364633 times.
✓ Branch 1 taken 283156 times.
647789 if(earlyret)
18923 364633 return ret;
18924
7/10
✓ Branch 0 taken 65586 times.
✓ Branch 1 taken 217570 times.
✓ Branch 2 taken 61720 times.
✓ Branch 3 taken 3866 times.
✓ Branch 4 taken 130 times.
✓ Branch 5 taken 61590 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 130 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
283156 if(dy < 0 && !ign_sv && sideview_mode() && IsSideSwim() && checkladder)
18925 {
18926 if(!iswaterex_z3(MAPCOMBO(x, y+(bigHitbox?0:8)-2), -1, x, y+(bigHitbox?0:8) - 2, true, false)
18927 && !canSideviewLadderRemote(x, y-4) && scr_canmove(0, -2, kb, true) && (y+(bigHitbox?0:8) - 4) > 0)
18928 {
18929 if (game->get_sideswim_jump() != 0)
18930 {
18931 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
18932 sfx(WAV_ZN1SPLASH,(int32_t)x);
18933 hopclk = 0;
18934 if (charging || spins) action = attacking;
18935 else action = none;
18936 }
18937 else
18938 {
18939 movexy(0,-1*dy,false,false,false);
18940 }
18941 }
18942 }
18943 283156 return ret;
18944 727656 }
18945 3596 bool HeroClass::can_movexy(zfix dx, zfix dy, bool kb, bool ign_sv, bool shove)
18946 {
18947
1/2
✓ Branch 0 taken 3596 times.
✗ Branch 1 not taken.
7192 return handle_movestate([&]()
18948 {
18949 3596 return movexy(dx,dy,kb,ign_sv,shove,true);
18950 });
18951 }
18952 bool HeroClass::moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
18953 {
18954 double v = degrees.getFloat() * PI / 180.0;
18955 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
18956 return movexy(dx, dy, kb, ign_sv, shove, earlyret);
18957 }
18958 bool HeroClass::can_moveAtAngle(zfix degrees, zfix px, bool kb, bool ign_sv, bool shove)
18959 {
18960 return handle_movestate([&]()
18961 {
18962 return moveAtAngle(degrees,px,kb,ign_sv,shove,true);
18963 });
18964 }
18965 440764 bool HeroClass::moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove, bool earlyret)
18966 {
18967
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 440762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
440764 static const zfix diagrate = zslongToFix(7071);
18968
6/13
✓ Branch 0 taken 440764 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 440764 times.
✓ Branch 4 taken 128017 times.
✓ Branch 5 taken 84306 times.
✓ Branch 6 taken 110138 times.
✓ Branch 7 taken 118303 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
440764 switch(NORMAL_DIR(dir))
18969 {
18970 case up:
18971 128017 return movexy(0, -px, kb, ign_sv, shove, earlyret);
18972 case down:
18973 84306 return movexy(0, px, kb, ign_sv, shove, earlyret);
18974 case left:
18975 110138 return movexy(-px, 0, kb, ign_sv, shove, earlyret);
18976 case right:
18977 118303 return movexy(px, 0, kb, ign_sv, shove, earlyret);
18978 case r_up:
18979 return movexy(px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
18980 case r_down:
18981 return movexy(px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
18982 case l_up:
18983 return movexy(-px*diagrate, -px*diagrate, kb, ign_sv, shove, earlyret);
18984 case l_down:
18985 return movexy(-px*diagrate, px*diagrate, kb, ign_sv, shove, earlyret);
18986 }
18987 return false;
18988 440764 }
18989 440764 bool HeroClass::can_moveDir(int dir, zfix px, bool kb, bool ign_sv, bool shove)
18990 {
18991
1/2
✓ Branch 0 taken 440764 times.
✗ Branch 1 not taken.
881528 return handle_movestate([&]()
18992 {
18993 440764 return moveDir(dir,px,kb,ign_sv,shove,true);
18994 });
18995 }
18996
18997
18998 402696 bool HeroClass::premove()
18999 {
19000
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402696 times.
402696 if(is_autowalking()) return true;
19001
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 402352 times.
402696 if(lstunclock) return false;
19002
4/4
✓ Branch 0 taken 3376 times.
✓ Branch 1 taken 398976 times.
✓ Branch 2 taken 109 times.
✓ Branch 3 taken 3267 times.
402352 if(is_conveyor_stunned) return (convey_forcex || convey_forcey);
19003 398976 int32_t xoff=x.getInt()&7;
19004 398976 int32_t yoff=y.getInt()&7;
19005
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 398976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
398976 if(NO_GRIDLOCK)
19006 {
19007 398976 xoff = 0;
19008 398976 yoff = 0;
19009 398976 }
19010 398976 int32_t push=pushing;
19011 398976 int32_t oldladderx=-1000, oldladdery=-1000; // moved here because linux complains "init crosses goto ~Koopa
19012 398976 int32_t flippers_id = current_item_id(itype_flippers);
19013 398976 itemdata const& itm = itemsbuf[flippers_id];
19014 398976 byte intbtn = byte(itm.misc3&0xFF);
19015 398976 bool dive_pressed = getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK | INPUT_PEEK);
19016 398976 bool eatdive = false;
19017
2/2
✓ Branch 0 taken 411 times.
✓ Branch 1 taken 398565 times.
398976 if(diveclk>0)
19018 {
19019
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 411 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
411 if (isSideViewHero() && get_qr(qr_SIDESWIM)) diveclk = 0;
19020 411 --diveclk;
19021
4/8
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 326 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 326 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
411 if(isDiving() && flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag2 && dive_pressed) //Cancellable Diving -V
19022 {
19023 diveclk = itemsbuf[flippers_id].misc2;
19024 eatdive = true;
19025 }
19026 411 }
19027
4/4
✓ Branch 0 taken 6251 times.
✓ Branch 1 taken 392314 times.
✓ Branch 2 taken 6240 times.
✓ Branch 3 taken 11 times.
398565 else if(action == swimming && dive_pressed)
19028 {
19029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 bool global_diving=(flippers_id > -1 && itemsbuf[flippers_id].flags & item_flag1);
19030 11 bool screen_diving=(hero_scr->flags5&fTOGGLEDIVING) != 0;
19031
19032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 if(global_diving==screen_diving)
19033 {
19034
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 diveclk = (flippers_id < 0 ? 80 : (itemsbuf[flippers_id].misc1 + itemsbuf[flippers_id].misc2));
19035 11 eatdive = true;
19036 11 }
19037 11 }
19038
2/2
✓ Branch 0 taken 398965 times.
✓ Branch 1 taken 11 times.
398976 if(eatdive)
19039 11 getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK);
19040
19041
1/2
✓ Branch 0 taken 398976 times.
✗ Branch 1 not taken.
398976 if(action==rafting)
19042 {
19043 do_rafting();
19044
19045 if(action==rafting)
19046 {
19047 return false;
19048 }
19049
19050
19051 set_respawn_point();
19052 trySideviewLadder();
19053 }
19054
19055 398976 int32_t olddirectwpn = directWpn; // To be reinstated if startwpn() fails
19056 398976 int32_t btnwpn = -1;
19057
19058 //&0xFFF removes the "bow & arrows" bitmask
19059 //The Quick Sword is allowed to interrupt attacks.
19060
4/4
✓ Branch 0 taken 388298 times.
✓ Branch 1 taken 10678 times.
✓ Branch 2 taken 261785 times.
✓ Branch 3 taken 126513 times.
398976 int32_t currentSwordOrWand = (itemsbuf[dowpn].type == itype_wand || itemsbuf[dowpn].type == itype_sword)?dowpn:-1;
19061
7/8
✓ Branch 0 taken 364616 times.
✓ Branch 1 taken 34360 times.
✓ Branch 2 taken 364550 times.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 5716 times.
✓ Branch 5 taken 28710 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 34426 times.
398976 if((!attackclk && action!=attacking && action != sideswimattacking) || ((attack==wSword || attack==wWand) && (itemsbuf[currentSwordOrWand].flags & item_flag5)))
19062 {
19063
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 364364 times.
364550 if (getInput(btnB, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
19064 {
19065 186 btnwpn=getItemFamily(itemsbuf,Bwpn);
19066
1/2
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
186 dowpn = NEG_OR_MASK(Bwpn,0xFFF);
19067 186 directWpn = directItemB;
19068 186 }
19069
2/2
✓ Branch 0 taken 2102 times.
✓ Branch 1 taken 362262 times.
364364 else if (getInput(btnA, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
19070 {
19071 2102 btnwpn=getItemFamily(itemsbuf,Awpn);
19072
1/2
✓ Branch 0 taken 2102 times.
✗ Branch 1 not taken.
2102 dowpn = NEG_OR_MASK(Awpn,0xFFF);
19073 2102 directWpn = directItemA;
19074 2102 }
19075
4/4
✓ Branch 0 taken 351949 times.
✓ Branch 1 taken 10313 times.
✓ Branch 2 taken 351826 times.
✓ Branch 3 taken 123 times.
362262 else if (get_qr(qr_SET_XBUTTON_ITEMS) && getInput(btnEx1, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
19076 {
19077 123 btnwpn=getItemFamily(itemsbuf,Xwpn);
19078
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 dowpn = NEG_OR_MASK(Xwpn,0xFFF);
19079 123 directWpn = directItemX;
19080 123 }
19081
4/4
✓ Branch 0 taken 351826 times.
✓ Branch 1 taken 10313 times.
✓ Branch 2 taken 351713 times.
✓ Branch 3 taken 113 times.
362139 else if (get_qr(qr_SET_YBUTTON_ITEMS) && getInput(btnEx2, INPUT_PRESS | INPUT_DRUNK | INPUT_HERO_ACTION))
19082 {
19083 113 btnwpn=getItemFamily(itemsbuf,Ywpn);
19084
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 dowpn = NEG_OR_MASK(Ywpn,0xFFF);
19085 113 directWpn = directItemY;
19086 113 }
19087
19088
2/2
✓ Branch 0 taken 131518 times.
✓ Branch 1 taken 233032 times.
364550 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
19089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 364550 times.
364550 if (on_cooldown(itmid))
19090 {
19091 directWpn = olddirectwpn;
19092 btnwpn = -1;
19093 dowpn = -1;
19094 did_scriptb = false;
19095 }
19096 else
19097 {
19098
1/2
✓ Branch 0 taken 364550 times.
✗ Branch 1 not taken.
364550 if(directWpn >= MAXITEMS) directWpn = -1;
19099
19100 // The Quick Sword only allows repeated sword or wand swings.
19101
3/8
✓ Branch 0 taken 364550 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 364550 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 364550 times.
364550 if((action==attacking||action==sideswimattacking) && ((attack==wSword && btnwpn!=itype_sword) || (attack==wWand && btnwpn!=itype_wand)))
19102 btnwpn=-1;
19103 }
19104 364550 }
19105
19106
2/2
✓ Branch 0 taken 137194 times.
✓ Branch 1 taken 261782 times.
398976 auto swordid = (directWpn>-1 ? directWpn : current_item_id(itype_sword));
19107
10/12
✓ Branch 0 taken 384374 times.
✓ Branch 1 taken 14602 times.
✓ Branch 2 taken 381627 times.
✓ Branch 3 taken 2747 times.
✓ Branch 4 taken 250210 times.
✓ Branch 5 taken 131417 times.
✓ Branch 6 taken 250210 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2102 times.
✓ Branch 9 taken 248108 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2102 times.
398976 if(can_attack() && (swordid > -1 && itemsbuf[swordid].type==itype_sword) && checkitem_jinx(swordid) && btnwpn==itype_sword && charging==0)
19108 {
19109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2102 times.
2102 attackid=directWpn>-1 ? directWpn : current_item_id(itype_sword);
19110
2/6
✓ Branch 0 taken 2102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2102 if(checkbunny(attackid) && (checkmagiccost(attackid) || !(itemsbuf[attackid].flags & item_flag6)))
19111 {
19112
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2102 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_SWORD_COST))
19113 {
19114 paymagiccost(attackid,true);
19115 misc_internal_hero_flags |= LF_PAID_SWORD_COST;
19116 }
19117 2102 SetAttack();
19118 2102 attack=wSword;
19119
19120 2102 attackclk=0;
19121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2102 times.
2102 sfx(itemsbuf[directWpn>-1 ? directWpn : current_item_id(itype_sword)].usesound, pan(x));
19122
19123
2/10
✓ Branch 0 taken 2102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
2102 if(dowpn>-1 && itemsbuf[dowpn].script!=0 && !did_scripta && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
19124 {
19125 if(!checkmagiccost(dowpn))
19126 {
19127 item_error();
19128 }
19129 else
19130 {
19131 //clear the item script stack for a new script
19132 int i = dowpn;
19133 FFCore.reset_script_engine_data(ScriptType::Item, i);
19134 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
19135 did_scripta=true;
19136 }
19137 }
19138 2102 }
19139 else
19140 {
19141 item_error();
19142 }
19143 2102 }
19144 else
19145 {
19146 396874 did_scripta=false;
19147 }
19148
19149
7/10
✓ Branch 0 taken 392314 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 392314 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 392314 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 392314 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 311 times.
✓ Branch 9 taken 392003 times.
398976 if(action!=swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !getOnSideviewLadder())
19150 {
19151
4/4
✓ Branch 0 taken 69003 times.
✓ Branch 1 taken 323000 times.
✓ Branch 2 taken 68995 times.
✓ Branch 3 taken 8 times.
392003 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && canSideviewLadder())
19152 {
19153 8 setOnSideviewLadder(true);
19154 8 }
19155
4/4
✓ Branch 0 taken 72790 times.
✓ Branch 1 taken 319205 times.
✓ Branch 2 taken 72789 times.
✓ Branch 3 taken 1 times.
391995 else if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && canSideviewLadder(true))
19156 {
19157 1 y+=1;
19158 1 setOnSideviewLadder(true);
19159 1 }
19160 392003 }
19161
19162 398976 int32_t wx=x;
19163 398976 int32_t wy=y;
19164
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 398976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
398976 if(conv_forcedir > -1 && !spins) dir = conv_forcedir;
19165
5/6
✓ Branch 0 taken 288697 times.
✓ Branch 1 taken 110279 times.
✓ Branch 2 taken 320 times.
✓ Branch 3 taken 398656 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 320 times.
398976 else if((action==none || action==walking) && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
19166 {
19167
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
320 if((xoff==0)||diagonalMovement)
19168 {
19169
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 130 times.
320 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = up;
19170
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 23 times.
320 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = down;
19171 320 }
19172
19173
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
320 if((yoff==0)||diagonalMovement)
19174 {
19175
2/2
✓ Branch 0 taken 305 times.
✓ Branch 1 taken 15 times.
320 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = left;
19176
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 54 times.
320 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = right;
19177 320 }
19178 320 }
19179
19180
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 79774 times.
✓ Branch 2 taken 86824 times.
✓ Branch 3 taken 116396 times.
✓ Branch 4 taken 115982 times.
398976 switch(dir)
19181 {
19182 case up:
19183 79774 wy-=16;
19184 79774 break;
19185
19186 case down:
19187 86824 wy+=16;
19188 86824 break;
19189
19190 case left:
19191 116396 wx-=16;
19192 116396 break;
19193
19194 case right:
19195 115982 wx+=16;
19196 115982 break;
19197 }
19198
19199 398976 do_lens();
19200
19201 398976 bool no_jinx = true;
19202
2/2
✓ Branch 0 taken 391036 times.
✓ Branch 1 taken 7940 times.
398976 bool liftonly = lift_wpn && (liftflags & LIFTFL_DIS_ITEMS);
19203
2/2
✓ Branch 0 taken 137194 times.
✓ Branch 1 taken 261782 times.
398976 auto itmid = directWpn>-1 ? directWpn : current_item_id(btnwpn);
19204
2/2
✓ Branch 0 taken 7940 times.
✓ Branch 1 taken 391036 times.
398976 if(liftonly)
19205 {
19206
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7940 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7940 if(replay_version_check(38) && btnwpn > -1)
19207 {
19208 no_jinx = checkitem_jinx(itmid);
19209 if(no_jinx)
19210 startwpn(itmid);
19211 directWpn = olddirectwpn;
19212 }
19213 7940 }
19214
6/8
✓ Branch 0 taken 384374 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 418 times.
✓ Branch 3 taken 383956 times.
✓ Branch 4 taken 418 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 418 times.
391036 else if(can_attack() && btnwpn>itype_sword && charging==0 && btnwpn!=itype_rupee) // This depends on item 0 being a rupee...
19215 {
19216 418 bool paidmagic = false;
19217
5/8
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 59 times.
418 if(btnwpn==itype_wand && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].type==itype_wand : false) : current_item(itype_wand)))
19218 {
19219
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 attackid=directWpn>-1 ? directWpn : current_item_id(itype_wand);
19220 59 no_jinx = checkitem_jinx(attackid);
19221
3/8
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
59 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
19222 {
19223
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_WAND_COST)){
19224 paymagiccost(attackid,true);
19225 misc_internal_hero_flags |= LF_PAID_WAND_COST;
19226 }
19227 59 SetAttack();
19228 59 attack=wWand;
19229 59 attackclk=0;
19230 59 }
19231 else
19232 {
19233 item_error();
19234 }
19235 59 }
19236
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
359 else if((btnwpn==itype_hammer)&&!((action==attacking||action==sideswimattacking) && attack==wHammer)
19237 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].type==itype_hammer : false) : current_item(itype_hammer)))
19238 {
19239 no_jinx = checkitem_jinx(dowpn);
19240 if(!(no_jinx && checkmagiccost(dowpn) && checkbunny(dowpn)))
19241 {
19242 item_error();
19243 }
19244 else
19245 {
19246 paymagiccost(dowpn);
19247 paidmagic = true;
19248 SetAttack();
19249 attack=wHammer;
19250 attackid=directWpn>-1 ? directWpn : current_item_id(itype_hammer);
19251 attackclk=0;
19252 }
19253 }
19254
4/6
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 308 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
410 else if((btnwpn==itype_candle)&&!((action==attacking||action==sideswimattacking) && attack==wFire)
19255
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 51 times.
51 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].type==itype_candle : false) : current_item(itype_candle)))
19256 {
19257 //checkbunny handled where magic cost is paid
19258
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 attackid=directWpn>-1 ? directWpn : current_item_id(itype_candle);
19259 51 no_jinx = checkitem_jinx(attackid);
19260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if(no_jinx)
19261 {
19262 51 SetAttack();
19263 51 attack=wFire;
19264 51 attackclk=0;
19265 51 }
19266 51 }
19267
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
308 else if((btnwpn==itype_cbyrna)&&!((action==attacking||action==sideswimattacking) && attack==wCByrna)
19268 && (directWpn>-1 ? (!item_disabled(directWpn) ? itemsbuf[directWpn].type==itype_cbyrna : false) : current_item(itype_cbyrna)))
19269 {
19270 attackid=directWpn>-1 ? directWpn : current_item_id(itype_cbyrna);
19271 no_jinx = checkitem_jinx(attackid);
19272 if(no_jinx && checkbunny(attackid) && ((!(itemsbuf[attackid].flags & item_flag6)) || checkmagiccost(attackid)))
19273 {
19274 if((itemsbuf[attackid].flags & item_flag6) && !(misc_internal_hero_flags & LF_PAID_CBYRNA_COST)){
19275 paymagiccost(attackid,true);
19276 misc_internal_hero_flags |= LF_PAID_CBYRNA_COST;
19277 }
19278 SetAttack();
19279 attack=wCByrna;
19280 attackclk=0;
19281 }
19282 else
19283 {
19284 item_error();
19285 }
19286 }
19287
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
314 else if((btnwpn==itype_bugnet)&&!((action==attacking||action==sideswimattacking) && attack==wBugNet)
19288
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 && (directWpn>-1 ? (!item_disabled(directWpn) && itemsbuf[directWpn].type==itype_bugnet) : current_item(itype_bugnet)))
19289 {
19290
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 attackid = directWpn>-1 ? directWpn : current_item_id(itype_bugnet);
19291 6 no_jinx = checkitem_jinx(attackid);
19292
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
6 if(no_jinx && checkbunny(attackid) && checkmagiccost(attackid))
19293 {
19294 6 paymagiccost(attackid);
19295 6 SetAttack();
19296 6 attack = wBugNet;
19297 6 attackclk = 0;
19298 6 sfx(itemsbuf[attackid].usesound);
19299 6 }
19300 else
19301 {
19302 item_error();
19303 }
19304 6 }
19305 else
19306 {
19307 302 no_jinx = checkitem_jinx(itmid);
19308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 302 times.
302 if(no_jinx)
19309 {
19310 302 paidmagic = startwpn(itmid);
19311
19312
1/2
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
302 if(paidmagic)
19313 {
19314
5/10
✓ Branch 0 taken 302 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 302 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 302 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 302 times.
302 if(action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning)
19315 {
19316 ;
19317 }
19318 else
19319 {
19320 302 SetAttack();
19321 302 attackclk=0;
19322 302 attack=none;
19323
19324
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 179 times.
302 if(btnwpn==itype_brang)
19325 {
19326 123 attack=wBrang;
19327 123 }
19328 }
19329 302 }
19330 else
19331 {
19332 // Weapon not started: directWpn should be reset to prev. value.
19333 directWpn = olddirectwpn;
19334 }
19335 302 }
19336 }
19337
19338
3/12
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 418 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
418 if(dowpn>-1 && no_jinx && itemsbuf[dowpn].script!=0 && !did_scriptb && !(FFCore.doscript(ScriptType::Item, dowpn) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
19339 {
19340 if(!((paidmagic || checkmagiccost(dowpn)) && checkbunny(dowpn)))
19341 {
19342 item_error();
19343 }
19344 else
19345 {
19346 // Only charge for magic if item's magic cost wasn't already charged
19347 // for the item's main use.
19348 if(!paidmagic && attack!=wWand)
19349 paymagiccost(dowpn);
19350 //clear the item script stack for a new script
19351 int i = dowpn;
19352 FFCore.reset_script_engine_data(ScriptType::Item, i);
19353 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
19354 did_scriptb=true;
19355 }
19356 }
19357
19358
6/12
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 418 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 418 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 418 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 418 times.
418 if(no_jinx && (action==casting || action==drowning || action==lavadrowning || action == sideswimcasting || action==sidedrowning))
19359 {
19360 return false;
19361 }
19362
1/2
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
418 if(!no_jinx)
19363 did_scriptb = false;
19364 418 }
19365 else
19366 {
19367 390618 did_scriptb=false;
19368 }
19369
19370
5/6
✓ Branch 0 taken 364616 times.
✓ Branch 1 taken 34360 times.
✓ Branch 2 taken 362030 times.
✓ Branch 3 taken 2586 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 362030 times.
398976 if(attackclk || action==attacking || action==sideswimattacking)
19371 {
19372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36946 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36946 if(conv_forcedir > -1 && !spins) dir = conv_forcedir;
19373
4/8
✓ Branch 0 taken 2586 times.
✓ Branch 1 taken 34360 times.
✓ Branch 2 taken 2586 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2586 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
36946 else if((attackclk==0) && action!=sideswimattacking && getOnSideviewLadder() && (get_qr(qr_SIDEVIEWLADDER_FACEUP)!=0)) //Allow DIR to change if standing still on sideview ladder, and force-face up.
19374 {
19375 if((xoff==0)||diagonalMovement)
19376 {
19377 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = up;
19378 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = down;
19379 }
19380
19381 if((yoff==0)||diagonalMovement)
19382 {
19383 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = left;
19384 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = right;
19385 }
19386 }
19387
19388 36946 bool attacked = doattack();
19389
19390 // This section below interferes with script-setting Hero->Dir, so it comes after doattack
19391
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36946 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36946 if(conv_forcedir > -1 && !spins) dir = conv_forcedir;
19392
8/12
✓ Branch 0 taken 36946 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26704 times.
✓ Branch 3 taken 10242 times.
✓ Branch 4 taken 4923 times.
✓ Branch 5 taken 21781 times.
✓ Branch 6 taken 4923 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4923 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 4923 times.
36946 else if(!inlikelike && attackclk>4 && (attackclk&3)==0 && charging==0 && spins==0 && action!=sideswimattacking)
19393 {
19394
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4923 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4923 if((xoff==0)||diagonalMovement)
19395 {
19396
2/2
✓ Branch 0 taken 4676 times.
✓ Branch 1 taken 247 times.
4923 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = up;
19397
2/2
✓ Branch 0 taken 4411 times.
✓ Branch 1 taken 512 times.
4923 if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = down;
19398
19399 4923 }
19400
19401
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4923 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4923 if((yoff==0)||diagonalMovement)
19402 {
19403
2/2
✓ Branch 0 taken 4428 times.
✓ Branch 1 taken 495 times.
4923 if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = left;
19404
2/2
✓ Branch 0 taken 4372 times.
✓ Branch 1 taken 551 times.
4923 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION)) dir = right;
19405 4923 }
19406 4923 }
19407
19408
6/10
✓ Branch 0 taken 34461 times.
✓ Branch 1 taken 2485 times.
✓ Branch 2 taken 34461 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34461 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34461 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 34461 times.
36946 if(attacked && (charging==0 && spins<=5) && jumping<1 && action!=sideswimattacking)
19409 {
19410 34461 return false;
19411 }
19412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2485 times.
2485 else if(!attacked)
19413 {
19414 // Spin attack - change direction
19415
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2485 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2485 if(spins>1 && attack != wHammer)
19416 {
19417 spins--;
19418
19419 if(spins%5==0)
19420 {
19421 int id = currentscroll > -1 ? currentscroll : (current_item_id(spins>5 ? itype_spinscroll2 : itype_spinscroll));
19422 sfx(itemsbuf[id].usesound,pan(x));
19423 }
19424 attackclk=1;
19425
19426 switch(dir)
19427 {
19428 case up:
19429 dir=left;
19430 break;
19431
19432 case right:
19433 dir=up;
19434 break;
19435
19436 case down:
19437 dir=right;
19438 break;
19439
19440 case left:
19441 dir=down;
19442 break;
19443 }
19444
19445 return false;
19446 }
19447 else
19448 {
19449 2485 spins=0;
19450 }
19451
19452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2485 times.
2485 if (IsSideSwim()) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
19453 2485 else {action=none; FFCore.setHeroAction(none);}
19454 2485 attackclk=0;
19455 2485 charging=0;
19456 2485 }
19457 2485 }
19458 364515 return true;
19459 402696 }
19460 364674 void HeroClass::movehero()
19461 {
19462 364674 bool earlyret = false;
19463
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 364674 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
364674 bool nohorz = (isdungeon() && (y<=26 || y>=world_h-42) && !get_qr(qr_FREEFORM) && !toogam);
19464
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 364674 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
364674 bool novert = (isdungeon() && (x<=26 || x>=world_w - 42) && !get_qr(qr_FREEFORM) && !toogam);
19465 364674 zfix dx, dy;
19466 364674 auto push=pushing;
19467 364674 pushing=0;
19468
19469
3/4
✓ Branch 0 taken 364515 times.
✓ Branch 1 taken 159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 364515 times.
364674 if(!is_conveyor_stunned && !is_autowalking()) //these do not apply to conveyor auto-walk
19470 {
19471
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 364451 times.
364515 if(pitslide()) //Check pit's 'pull'. If true, then Hero cannot fight the pull.
19472 64 return;
19473
19474
2/2
✓ Branch 0 taken 118078 times.
✓ Branch 1 taken 246373 times.
364451 if(action==walking) //still walking
19475 {
19476
9/10
✓ Branch 0 taken 180908 times.
✓ Branch 1 taken 65465 times.
✓ Branch 2 taken 114158 times.
✓ Branch 3 taken 66750 times.
✓ Branch 4 taken 60217 times.
✓ Branch 5 taken 53941 times.
✓ Branch 6 taken 3143 times.
✓ Branch 7 taken 57074 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 3143 times.
246373 if (!getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && !getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && !autostep)
19477 {
19478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3143 times.
3143 if(attackclk>0) SetAttack();
19479 3143 else {action = none; FFCore.setHeroAction(none);}
19480 3143 hero_count=-1;
19481 3143 earlyret = true;
19482 3143 goto newmove_slide;
19483 }
19484
19485 243230 autostep=false;
19486 243230 } // endif (action==walking)
19487
19488
14/24
✓ Branch 0 taken 354646 times.
✓ Branch 1 taken 6662 times.
✓ Branch 2 taken 354646 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 354646 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 354646 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 354646 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 354646 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 354646 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 354646 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 354646 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 354646 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 354646 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 2598 times.
✓ Branch 23 taken 352048 times.
361308 if((action!=swimming)&&(action!=sideswimming)&&(action !=sideswimhit)&&(action !=sideswimattacking)&&(action!=casting)&&(action!=sideswimcasting)&&(action!=drowning)&&(action!=sidedrowning)&&(action!=lavadrowning) && charging==0 && spins==0 && jumping<1)
19489 {
19490 352048 action=none; FFCore.setHeroAction(none);
19491 352048 }
19492 361308 }
19493
19494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 361467 times.
817430 if(is_autowalking())
19495 {
19496 if(check_pitslide() > -1)
19497 try_hover();
19498 }
19499
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 361308 times.
361467 else if(is_conveyor_stunned)
19500 {
19501 159 dx = convey_forcex;
19502 159 dy = convey_forcey;
19503 159 convey_forcex = 0;
19504 159 convey_forcey = 0;
19505
2/2
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 1 times.
159 if(action != walking)
19506 {
19507 1 action = walking; FFCore.setHeroAction(walking);
19508 1 }
19509 159 }
19510
1/2
✓ Branch 0 taken 361308 times.
✗ Branch 1 not taken.
361308 else if(diagonalMovement)
19511 {
19512
5/5
✓ Branch 0 taken 104102 times.
✓ Branch 1 taken 49207 times.
✓ Branch 2 taken 53209 times.
✓ Branch 3 taken 74097 times.
✓ Branch 4 taken 80693 times.
361308 switch(holddir)
19513 {
19514 case up:
19515
2/2
✓ Branch 0 taken 47248 times.
✓ Branch 1 taken 1959 times.
49207 if (!getInput(btnUp, INPUT_HERO_ACTION))
19516 {
19517 1959 holddir=-1;
19518 1959 }
19519
19520 49207 break;
19521
19522 case down:
19523
2/2
✓ Branch 0 taken 51211 times.
✓ Branch 1 taken 1998 times.
53209 if (!getInput(btnDown, INPUT_HERO_ACTION))
19524 {
19525 1998 holddir=-1;
19526 1998 }
19527
19528 53209 break;
19529
19530 case left:
19531
2/2
✓ Branch 0 taken 71726 times.
✓ Branch 1 taken 2371 times.
74097 if (!getInput(btnLeft, INPUT_HERO_ACTION))
19532 {
19533 2371 holddir=-1;
19534 2371 }
19535
19536 74097 break;
19537
19538 case right:
19539
2/2
✓ Branch 0 taken 78282 times.
✓ Branch 1 taken 2411 times.
80693 if (!getInput(btnRight, INPUT_HERO_ACTION))
19540 {
19541 2411 holddir=-1;
19542 2411 }
19543
19544 80693 break;
19545
19546 default:
19547 104102 break;
19548 } //end switch
19549
19550
6/6
✓ Branch 0 taken 69011 times.
✓ Branch 1 taken 292297 times.
✓ Branch 2 taken 67047 times.
✓ Branch 3 taken 1964 times.
✓ Branch 4 taken 47248 times.
✓ Branch 5 taken 49212 times.
361308 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == up) && !novert)
19551 {
19552
4/10
✓ Branch 0 taken 49212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49212 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49212 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 49212 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
49212 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
19553 {
19554 49212 dir=up;
19555 49212 }
19556 49212 holddir=up;
19557
19558
5/6
✓ Branch 0 taken 8041 times.
✓ Branch 1 taken 41171 times.
✓ Branch 2 taken 8033 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8033 times.
49212 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != left && !nohorz)
19559 {
19560 8033 shiftdir=right;
19561
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8033 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8033 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
19562
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8033 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8033 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
19563 8033 }
19564
5/6
✓ Branch 0 taken 6156 times.
✓ Branch 1 taken 35023 times.
✓ Branch 2 taken 6149 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6149 times.
41179 else if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != right && !nohorz)
19565 {
19566 6149 shiftdir=left;
19567
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6149 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
19568
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6149 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
19569 6149 }
19570 else
19571 {
19572 35030 shiftdir=-1;
19573 }
19574 49212 }
19575
6/6
✓ Branch 0 taken 70275 times.
✓ Branch 1 taken 336317 times.
✓ Branch 2 taken 68273 times.
✓ Branch 3 taken 2002 times.
✓ Branch 4 taken 17062 times.
✓ Branch 5 taken 53213 times.
406592 else if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == down) && !novert)
19576 {
19577
4/10
✓ Branch 0 taken 53213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53213 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53213 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 53213 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
53213 if(charging==0 && spins==0 && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR)))
19578 {
19579 53213 dir=down;
19580 53213 }
19581 53213 holddir=down;
19582
19583
5/6
✓ Branch 0 taken 6794 times.
✓ Branch 1 taken 46419 times.
✓ Branch 2 taken 6779 times.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6779 times.
53213 if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != left && !nohorz)
19584 {
19585 6779 shiftdir=right;
19586
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 6779 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6779 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = right;
19587
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6779 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6779 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = right;
19588 6779 }
19589
5/6
✓ Branch 0 taken 8568 times.
✓ Branch 1 taken 37866 times.
✓ Branch 2 taken 8557 times.
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8557 times.
46434 else if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != right && !nohorz)
19590 {
19591 8557 shiftdir=left;
19592
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 8557 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
8557 if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (charging==0 && spins==0)) dir = left;
19593
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8557 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8557 if (!IsSideSwim() || (charging==0 && spins==0)) sideswimdir = left;
19594 8557 }
19595 else
19596 {
19597 37877 shiftdir=-1;
19598 }
19599 53213 }
19600
6/6
✓ Branch 0 taken 74240 times.
✓ Branch 1 taken 279139 times.
✓ Branch 2 taken 71866 times.
✓ Branch 3 taken 2374 times.
✓ Branch 4 taken 140 times.
✓ Branch 5 taken 74100 times.
353379 else if (getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == left) && !nohorz)
19601 {
19602
3/6
✓ Branch 0 taken 74100 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74100 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 74100 times.
74100 if(charging==0 && spins==0 && action != sideswimattacking)
19603 {
19604 74100 dir=left;
19605 74100 }
19606 74100 sideswimdir = left;
19607 74100 holddir=left;
19608
19609
4/6
✓ Branch 0 taken 8531 times.
✓ Branch 1 taken 65569 times.
✓ Branch 2 taken 8531 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8531 times.
74100 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != down && !novert)
19610 {
19611 8531 shiftdir=up;
19612 8531 }
19613
5/6
✓ Branch 0 taken 8153 times.
✓ Branch 1 taken 57416 times.
✓ Branch 2 taken 8152 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8152 times.
65569 else if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != up && !novert)
19614 {
19615 8152 shiftdir=down;
19616 8152 }
19617 else
19618 {
19619 57417 shiftdir=-1;
19620 }
19621 74100 }
19622
5/6
✓ Branch 0 taken 80693 times.
✓ Branch 1 taken 198586 times.
✓ Branch 2 taken 78282 times.
✓ Branch 3 taken 2411 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 80693 times.
279279 else if (getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) && (holddir == -1 || holddir == right) && !nohorz)
19623 {
19624
3/6
✓ Branch 0 taken 80693 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80693 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 80693 times.
80693 if(charging==0 && spins==0 && action != sideswimattacking)
19625 {
19626 80693 dir=right;
19627 80693 }
19628 80693 sideswimdir = right;
19629 80693 holddir=right;
19630
19631
4/6
✓ Branch 0 taken 11268 times.
✓ Branch 1 taken 69425 times.
✓ Branch 2 taken 11268 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11268 times.
80693 if (getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != down && !novert)
19632 {
19633 11268 shiftdir=up;
19634 11268 }
19635
5/6
✓ Branch 0 taken 8907 times.
✓ Branch 1 taken 60518 times.
✓ Branch 2 taken 8905 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 8905 times.
69425 else if (getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION) && shiftdir != up && !novert)
19636 {
19637 8905 shiftdir=down;
19638 8905 }
19639 else
19640 {
19641 60520 shiftdir=-1;
19642 }
19643 80693 }
19644 else
19645 {
19646 198586 int32_t wtry = iswaterex_z3(MAPCOMBO(x,y+15), -1, x,y+15, true, false);
19647 198586 int32_t wtry8 = iswaterex_z3(MAPCOMBO(x+15,y+15), -1, x+15,y+15, true, false);
19648 198586 int32_t wtrx = iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?0:8)), -1, x,y+(bigHitbox?0:8), true, false);
19649 198586 int32_t wtrx8 = iswaterex_z3(MAPCOMBO(x+15,y+(bigHitbox?0:8)), -1, x+15,y+(bigHitbox?0:8), true, false);
19650 198586 int32_t wtrc = iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?8:12)), -1, x+8,y+(bigHitbox?8:12), true, false);
19651
19652
9/12
✓ Branch 0 taken 28585 times.
✓ Branch 1 taken 170001 times.
✓ Branch 2 taken 28528 times.
✓ Branch 3 taken 57 times.
✓ Branch 4 taken 185 times.
✓ Branch 5 taken 28343 times.
✓ Branch 6 taken 28528 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 28528 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28528 times.
✗ Branch 11 not taken.
198586 if(can_use_item(itype_flippers,i_flippers)&&current_item(itype_flippers) >= combobuf[wtrc].attribytes[0]&&(!(combobuf[wtrc].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))&&!(ladderx+laddery)&&z==0&&fakez==0)
19653 {
19654
8/12
✓ Branch 0 taken 579 times.
✓ Branch 1 taken 27949 times.
✓ Branch 2 taken 311 times.
✓ Branch 3 taken 268 times.
✓ Branch 4 taken 294 times.
✓ Branch 5 taken 17 times.
✓ Branch 6 taken 294 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 294 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
28528 if(wtrx&&wtrx8&&wtry&&wtry8 && !DRIEDLAKE)
19655 {
19656 //action=swimming;
19657
2/12
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 294 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
294 if(action !=none && action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking && !isSideViewHero())
19658 {
19659 hopclk = 0xFF;
19660 }
19661 294 }
19662 28528 }
19663 198586 earlyret = true;
19664 }
19665
2/2
✓ Branch 0 taken 198586 times.
✓ Branch 1 taken 257218 times.
455804 if(earlyret)
19666 198586 dx = dy = 0;
19667 257218 else get_move(holddir,dx,dy,dir);
19668 455804 }
19669 else //4-way
19670 {
19671 shiftdir = -1;
19672 holddir = -1;
19673 if (!novert && getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION))
19674 {
19675 holddir = dir = up;
19676 }
19677 else if (!novert && getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION))
19678 {
19679 holddir = dir = down;
19680 }
19681 else if (!nohorz && getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION))
19682 {
19683 holddir = dir = left;
19684 }
19685 else if (!nohorz && getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION))
19686 {
19687 holddir = dir = right;
19688 }
19689 get_move(holddir,dx,dy,dir);
19690 }
19691
19692 newmove_slide:
19693
3/4
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 458947 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 159 times.
459106 if(conv_forcedir > -1 && !spins)
19694 159 dir = conv_forcedir;
19695
3/4
✓ Branch 0 taken 364451 times.
✓ Branch 1 taken 94655 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 364451 times.
459106 if(!is_conveyor_stunned && !is_autowalking())
19696 {
19697
6/8
✓ Branch 0 taken 363363 times.
✓ Branch 1 taken 1088 times.
✓ Branch 2 taken 363363 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2204 times.
✓ Branch 5 taken 361159 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2204 times.
364451 bool is_inair = (z > 0 || fakez > 0) || (sideview_mode() && !get_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW) && !isStanding(true));
19698 364451 auto ic = ice_combo;
19699
2/2
✓ Branch 0 taken 2706 times.
✓ Branch 1 taken 361745 times.
364451 if(!is_inair) //maintain momentum when jumping
19700 {
19701 361745 const int sens = 2;
19702
3/4
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 361159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 586 times.
361745 if(sideview_mode() && !get_qr(qr_BROKEN_ICY_FLOOR_SIDEVIEW)) // check *below you* in sideview
19703 {
19704 586 int xs[] = {x+sens, x+15-sens};
19705 586 bool found = false;
19706
2/2
✓ Branch 0 taken 586 times.
✓ Branch 1 taken 1172 times.
1758 for(int q = 0; q < 2; ++q)
19707 {
19708 1172 auto ice = get_icy(xs[q], y+16, ICY_PLAYER);
19709
1/2
✓ Branch 0 taken 1172 times.
✗ Branch 1 not taken.
1172 if(ice)
19710 {
19711 ic = ice_combo = ice;
19712 found = true;
19713 break;
19714 }
19715 1172 }
19716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 586 times.
586 if(!found)
19717 586 ic = ice_combo = 0;
19718 586 }
19719 else
19720 {
19721 361159 auto ty = y+(bigHitbox?0:8);
19722 361159 int xs[] = {x+7, x+sens, x+sens, x+15-sens, x+15-sens};
19723 361159 int ys[] = {y+(bigHitbox?8:12), ty+sens, y+15-sens, ty+sens, y+15-sens};
19724 361159 bool found = false;
19725
2/2
✓ Branch 0 taken 361159 times.
✓ Branch 1 taken 1805795 times.
2166954 for(int q = 0; q < 5; ++q)
19726 {
19727 1805795 auto ice = get_icy(xs[q], ys[q], ICY_PLAYER);
19728
1/2
✓ Branch 0 taken 1805795 times.
✗ Branch 1 not taken.
1805795 if(ice)
19729 {
19730 ic = ice_combo = ice;
19731 found = true;
19732 break;
19733 }
19734 1805795 }
19735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 361159 times.
361159 if(!found)
19736 361159 ic = ice_combo = 0;
19737 }
19738 361745 }
19739
2/2
✓ Branch 0 taken 364291 times.
✓ Branch 1 taken 160 times.
364451 if(script_ice_combo)
19740 {
19741
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if((unsigned(script_ice_combo) < MAXCOMBOS) && check_icy(combobuf[script_ice_combo], ICY_PLAYER))
19742 160 ic = script_ice_combo;
19743 else ic = 0;
19744 160 }
19745
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 364291 times.
364451 if(ic)
19746 {
19747 160 handle_slide(combobuf[ic], dx, dy);
19748 160 earlyret = false;
19749 160 }
19750 364291 else clear_ice();
19751 364451 }
19752 94655 else clear_ice();
19753
2/2
✓ Branch 0 taken 107073 times.
✓ Branch 1 taken 352033 times.
459106 if(earlyret)
19754 107073 return;
19755
19756
2/2
✓ Branch 0 taken 313774 times.
✓ Branch 1 taken 38259 times.
352033 if(!new_engine_move(dx,dy))
19757 38259 pushing = push+1;
19758 459170 }
19759
19760 418394 void HeroClass::get_move(int movedir, zfix& dx, zfix& dy, int32_t& facedir)
19761 {
19762 418394 dx = 0; dy = 0;
19763
6/8
✓ Branch 0 taken 257218 times.
✓ Branch 1 taken 161176 times.
✓ Branch 2 taken 257218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257218 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 161176 times.
✓ Branch 7 taken 418394 times.
418394 if(inlikelike || lstunclock > 0 || is_conveyor_stunned || movedir < 0)
19764 322352 return;
19765
19766 418394 zfix base_movepix(zfix(steprate) / 100);
19767 418394 zfix movepix(base_movepix);
19768 418394 zfix up_step(zfix(game->get_sideswim_up()) / 100);
19769 418394 zfix left_step(zfix(game->get_sideswim_side()) / 100);
19770 418394 zfix right_step(zfix(game->get_sideswim_side()) / 100);
19771 418394 zfix down_step(zfix(game->get_sideswim_down()) / 100);
19772 418394 std::vector<zfix*> steps;
19773
2/2
✓ Branch 0 taken 257218 times.
✓ Branch 1 taken 161176 times.
418394 steps.push_back(&movepix);
19774
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 steps.push_back(&up_step);
19775
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 steps.push_back(&left_step);
19776
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 steps.push_back(&right_step);
19777
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 steps.push_back(&down_step);
19778
19779
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 mod_steps(steps);
19780
19781
2/4
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257218 times.
✗ Branch 3 not taken.
257218 up_step = -up_step;
19782
2/4
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 257218 times.
✗ Branch 3 not taken.
257218 left_step = -left_step;
19783
19784
19785
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 zfix step(movepix);
19786
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 zfix step_diag(movepix);
19787
19788
19789
1/2
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
257218 if (diagonalMovement)
19790 {
19791
6/6
✓ Branch 0 taken 208006 times.
✓ Branch 1 taken 49212 times.
✓ Branch 2 taken 43344 times.
✓ Branch 3 taken 251350 times.
✓ Branch 4 taken 87719 times.
✓ Branch 5 taken 4837 times.
392212 if (((movedir == up || movedir == down) && (shiftdir == left || shiftdir == right)) ||
19792
4/4
✓ Branch 0 taken 153600 times.
✓ Branch 1 taken 97750 times.
✓ Branch 2 taken 37244 times.
✓ Branch 3 taken 190844 times.
251350 (movedir == left || movedir == right) && (shiftdir == up || shiftdir == down))
19793 {
19794
4/6
✓ Branch 0 taken 66374 times.
✓ Branch 1 taken 161176 times.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
227550 step = STEP_DIAGONAL(step);
19795
3/6
✓ Branch 0 taken 66374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
66374 up_step = STEP_DIAGONAL(up_step);
19796
3/6
✓ Branch 0 taken 66374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
66374 left_step = STEP_DIAGONAL(left_step);
19797
3/6
✓ Branch 0 taken 66374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
66374 right_step = STEP_DIAGONAL(right_step);
19798
3/6
✓ Branch 0 taken 66374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 66374 times.
✗ Branch 5 not taken.
66374 down_step = STEP_DIAGONAL(down_step);
19799 66374 }
19800
4/5
✓ Branch 0 taken 49212 times.
✓ Branch 1 taken 53213 times.
✓ Branch 2 taken 74100 times.
✓ Branch 3 taken 80693 times.
✗ Branch 4 not taken.
257218 switch (movedir)
19801 {
19802 case up:
19803
3/3
✓ Branch 0 taken 6149 times.
✓ Branch 1 taken 8033 times.
✓ Branch 2 taken 35030 times.
49212 switch (shiftdir)
19804 {
19805 case left:
19806
4/10
✓ Branch 0 taken 6149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6149 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 6149 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6149 times.
✗ Branch 9 not taken.
6149 dx = IsSideSwim() ? left_step : -step;
19807 6149 break;
19808 case right:
19809
3/6
✓ Branch 0 taken 8033 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8033 times.
✓ Branch 4 taken 8033 times.
✗ Branch 5 not taken.
8033 dx = IsSideSwim() ? right_step : step;
19810 8033 break;
19811 }
19812
2/4
✓ Branch 0 taken 49212 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 49212 times.
49212 if (IsSideSwim())
19813 {
19814 dy = up_step;
19815 }
19816
2/4
✓ Branch 0 taken 49212 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49212 times.
✗ Branch 3 not taken.
49212 else dy = -step;
19817 49212 break;
19818 case down:
19819
3/3
✓ Branch 0 taken 8557 times.
✓ Branch 1 taken 6779 times.
✓ Branch 2 taken 37877 times.
53213 switch (shiftdir)
19820 {
19821 case left:
19822
2/4
✓ Branch 0 taken 8557 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8557 times.
✗ Branch 3 not taken.
8557 dx = -step;
19823
2/6
✓ Branch 0 taken 8557 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8557 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8557 if (IsSideSwim()) dx = left_step;
19824 8557 break;
19825 case right:
19826
1/2
✓ Branch 0 taken 6779 times.
✗ Branch 1 not taken.
6779 dx = step;
19827
2/6
✓ Branch 0 taken 6779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6779 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6779 if (IsSideSwim()) dx = right_step;
19828 6779 break;
19829 }
19830
3/6
✓ Branch 0 taken 53213 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 53213 times.
✓ Branch 4 taken 53213 times.
✗ Branch 5 not taken.
53213 dy = IsSideSwim() ? down_step : step;
19831 53213 break;
19832 case left:
19833
3/3
✓ Branch 0 taken 8531 times.
✓ Branch 1 taken 8152 times.
✓ Branch 2 taken 57417 times.
74100 switch (shiftdir)
19834 {
19835 case up:
19836
2/4
✓ Branch 0 taken 8531 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8531 times.
8531 if (IsSideSwim())
19837 {
19838 dy = up_step;
19839 }
19840
2/4
✓ Branch 0 taken 8531 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8531 times.
✗ Branch 3 not taken.
8531 else dy = -step;
19841 8531 break;
19842 case down:
19843
1/2
✓ Branch 0 taken 8152 times.
✗ Branch 1 not taken.
8152 dy = step;
19844
2/6
✓ Branch 0 taken 8152 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8152 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8152 if (IsSideSwim()) dy = down_step;
19845 8152 break;
19846 }
19847
4/10
✓ Branch 0 taken 74100 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 74100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 74100 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 74100 times.
✗ Branch 9 not taken.
74100 dx = IsSideSwim() ? left_step : -step;
19848 74100 break;
19849 case right:
19850
3/3
✓ Branch 0 taken 11268 times.
✓ Branch 1 taken 8905 times.
✓ Branch 2 taken 60520 times.
80693 switch (shiftdir)
19851 {
19852 case up:
19853
4/8
✓ Branch 0 taken 11268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11268 times.
✗ Branch 7 not taken.
11268 if (!IsSideSwim()) dy = -step;
19854
2/4
✓ Branch 0 taken 11268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11268 times.
11268 if (IsSideSwim())
19855 {
19856 dy = up_step;
19857 }
19858 11268 break;
19859 case down:
19860
1/2
✓ Branch 0 taken 8905 times.
✗ Branch 1 not taken.
8905 dy = step;
19861
2/6
✓ Branch 0 taken 8905 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8905 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8905 if (IsSideSwim()) dy = down_step;
19862 8905 break;
19863 }
19864
3/6
✓ Branch 0 taken 80693 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 80693 times.
✓ Branch 4 taken 80693 times.
✗ Branch 5 not taken.
80693 dx = IsSideSwim() ? right_step : step;
19865 80693 break;
19866 };
19867 257218 }
19868 else
19869 {
19870 switch (movedir)
19871 {
19872 case up:
19873 dy = IsSideSwim() ? up_step : -step;
19874 break;
19875 case down:
19876 dy = IsSideSwim() ? down_step : step;
19877 break;
19878 case left:
19879 dx = IsSideSwim() ? left_step : -step;
19880 break;
19881 case right:
19882 dx = IsSideSwim() ? right_step : step;
19883 break;
19884 };
19885 }
19886
19887
5/8
✓ Branch 0 taken 257218 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 761 times.
✓ Branch 3 taken 256457 times.
✓ Branch 4 taken 761 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 761 times.
257218 if (isSideViewHero() && slopeid)
19888 {
19889 dy += (dx*slopeid);
19890 }
19891
19892
6/18
✗ Branch 0 not taken.
✓ Branch 1 taken 257218 times.
✓ Branch 2 taken 257218 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 257218 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 257218 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 257218 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 257218 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
257218 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down))) //!DIRECTION SET
19893 {
19894 257218 facedir = movedir;
19895 257218 }
19896 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (movedir == up || movedir == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
19897 {
19898 facedir = shiftdir;
19899 }
19900 579570 }
19901
19902 257537 bool HeroClass::new_engine_move(zfix dx, zfix dy) //no collision check
19903 {
19904
3/6
✓ Branch 0 taken 72957 times.
✓ Branch 1 taken 184580 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 72957 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
257537 if(!dx && !dy && !is_autowalking()) return true;
19905
5/8
✓ Branch 0 taken 251247 times.
✓ Branch 1 taken 6290 times.
✓ Branch 2 taken 251247 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 251247 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 251247 times.
257537 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
19906 {
19907 251247 herostep();
19908
19909 //ack... don't walk if in midair! -DD
19910
11/14
✓ Branch 0 taken 251247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 251247 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 250270 times.
✓ Branch 5 taken 977 times.
✓ Branch 6 taken 250270 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 761 times.
✓ Branch 9 taken 249509 times.
✓ Branch 10 taken 652 times.
✓ Branch 11 taken 109 times.
✓ Branch 12 taken 200 times.
✓ Branch 13 taken 452 times.
251247 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
19911 {
19912 249818 action=walking; FFCore.setHeroAction(walking);
19913 249818 }
19914
19915
2/2
✓ Branch 0 taken 238059 times.
✓ Branch 1 taken 13188 times.
251247 if(++hero_count > (16*hero_animation_speed))
19916 13188 hero_count=0;
19917 251247 }
19918
2/2
✓ Branch 0 taken 3148 times.
✓ Branch 1 taken 3142 times.
6290 else if(!(frame & 1))
19919 {
19920 3142 herostep();
19921 3142 }
19922
19923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 257537 times.
257537 if(is_autowalking())
19924 autowalk_move();
19925
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 257537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
257537 else if(charging==0 || attack!=wHammer)
19926 257537 return movexy(dx,dy,false,false,true);
19927 return true;
19928 257537 }
19929
19930 7461833 void HeroClass::moveOld(int32_t d2)
19931 {
19932 static bool totalskip = false;
19933
19934
3/6
✓ Branch 0 taken 7461833 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7461833 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7461833 times.
7461833 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
19935 return;
19936
19937 7461833 int32_t dx=0,dy=0;
19938 7461833 int32_t xstep=lsteps[x.getInt()&7];
19939 7461833 int32_t ystep=lsteps[y.getInt()&7];
19940 7461833 int32_t z3skip=0;
19941 7461833 int32_t z3diagskip=0;
19942
5/6
✓ Branch 0 taken 200742 times.
✓ Branch 1 taken 7261091 times.
✓ Branch 2 taken 200680 times.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
14722986 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && ((z==0 && fakez == 0) || hero_scr->flags2&fAIRCOMBOS)) ||
19943
5/6
✓ Branch 0 taken 190641 times.
✓ Branch 1 taken 7070512 times.
✓ Branch 2 taken 104043 times.
✓ Branch 3 taken 86598 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 104043 times.
7261153 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement);
19944
2/2
✓ Branch 0 taken 7436018 times.
✓ Branch 1 taken 25815 times.
7461833 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & item_flag10);
19945 7461833 bool is_swimming = (action == swimming);
19946
19947 //slow walk combo, or charging, moves at 2/3 speed
19948 if(
19949
4/4
✓ Branch 0 taken 7360999 times.
✓ Branch 1 taken 100834 times.
✓ Branch 2 taken 201043 times.
✓ Branch 3 taken 7159956 times.
7562667 (!is_swimming && (slowcharging ^ slowcombo))||
19950
2/2
✓ Branch 0 taken 100834 times.
✓ Branch 1 taken 7159956 times.
7260790 (is_swimming && (zinit.hero_swim_speed>60))
19951 )
19952 {
19953 301877 totalskip = false;
19954
19955
2/2
✓ Branch 0 taken 49244 times.
✓ Branch 1 taken 252633 times.
301877 if(diagonalMovement)
19956 {
19957 49244 skipstep=(skipstep+1)%6;
19958
19959
2/2
✓ Branch 0 taken 25024 times.
✓ Branch 1 taken 24220 times.
49244 if(skipstep%2==0) z3skip=1;
19960 25024 else z3skip=0;
19961
19962
2/2
✓ Branch 0 taken 33205 times.
✓ Branch 1 taken 16039 times.
49244 if(skipstep%3==0) z3diagskip=1;
19963 33205 else z3diagskip=0;
19964 49244 }
19965 else
19966 {
19967
2/2
✓ Branch 0 taken 165339 times.
✓ Branch 1 taken 87294 times.
252633 if(d2<left)
19968 {
19969
2/2
✓ Branch 0 taken 99954 times.
✓ Branch 1 taken 65385 times.
165339 if(ystep>1)
19970 {
19971 65385 skipstep^=1;
19972 65385 ystep=skipstep;
19973 65385 }
19974 165339 }
19975 else
19976 {
19977
2/2
✓ Branch 0 taken 53050 times.
✓ Branch 1 taken 34244 times.
87294 if(xstep>1)
19978 {
19979 34244 skipstep^=1;
19980 34244 xstep=skipstep;
19981 34244 }
19982 }
19983 }
19984 301877 }
19985 // else if(is_swimming || (slowcharging && slowcombo))
19986 else if(
19987
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7159956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7160067 (is_swimming && (zinit.hero_swim_speed<60))||
19988
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 7159845 times.
7159956 (slowcharging && slowcombo)
19989 )
19990 {
19991 //swimming, or charging on a slow combo, moves at 1/2 speed
19992 111 totalskip = !totalskip;
19993
19994
1/2
✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
111 if(diagonalMovement)
19995 {
19996 skipstep=0;
19997 }
19998 111 }
19999 else
20000 {
20001 7159845 totalskip = false;
20002
20003
2/2
✓ Branch 0 taken 5124956 times.
✓ Branch 1 taken 2034889 times.
7159845 if(diagonalMovement)
20004 {
20005 2034889 skipstep=0;
20006 2034889 }
20007 }
20008
20009
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 7461777 times.
7461833 if(!totalskip)
20010 {
20011
2/2
✓ Branch 0 taken 2084133 times.
✓ Branch 1 taken 5377644 times.
7461777 if(diagonalMovement)
20012 {
20013
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 446218 times.
✓ Branch 2 taken 376935 times.
✓ Branch 3 taken 662678 times.
✓ Branch 4 taken 598302 times.
2084133 switch(d2)
20014 {
20015 case up:
20016
2/2
✓ Branch 0 taken 45459 times.
✓ Branch 1 taken 400759 times.
446218 if(shiftdir==left)
20017 {
20018
2/2
✓ Branch 0 taken 35961 times.
✓ Branch 1 taken 9498 times.
45459 if(walkable)
20019 {
20020 35961 dy-=1-z3diagskip;
20021 35961 dx-=1-z3diagskip;
20022 35961 z3step=2;
20023 35961 }
20024 else
20025 {
20026 9498 dx-=1-z3diagskip;
20027 9498 z3step=2;
20028 }
20029 45459 }
20030
2/2
✓ Branch 0 taken 54669 times.
✓ Branch 1 taken 346090 times.
400759 else if(shiftdir==right)
20031 {
20032
2/2
✓ Branch 0 taken 43543 times.
✓ Branch 1 taken 11126 times.
54669 if(walkable)
20033 {
20034 43543 dy-=1-z3diagskip;
20035 43543 dx+=1-z3diagskip;
20036 43543 z3step=2;
20037 43543 }
20038 else
20039 {
20040 11126 dx+=1-z3diagskip;
20041 11126 z3step=2;
20042 }
20043 54669 }
20044 else
20045 {
20046
2/2
✓ Branch 0 taken 62104 times.
✓ Branch 1 taken 283986 times.
346090 if(walkable)
20047 {
20048 283986 dy-=z3step-z3skip;
20049 283986 z3step=(z3step%2)+1;
20050 283986 }
20051 }
20052
20053 446218 break;
20054
20055 case down:
20056
2/2
✓ Branch 0 taken 50975 times.
✓ Branch 1 taken 325960 times.
376935 if(shiftdir==left)
20057 {
20058
2/2
✓ Branch 0 taken 38415 times.
✓ Branch 1 taken 12560 times.
50975 if(walkable)
20059 {
20060 38415 dy+=1-z3diagskip;
20061 38415 dx-=1-z3diagskip;
20062 38415 z3step=2;
20063 38415 }
20064 else
20065 {
20066 12560 dx-=1-z3diagskip;
20067 12560 z3step=2;
20068 }
20069 50975 }
20070
2/2
✓ Branch 0 taken 52314 times.
✓ Branch 1 taken 273646 times.
325960 else if(shiftdir==right)
20071 {
20072
2/2
✓ Branch 0 taken 39775 times.
✓ Branch 1 taken 12539 times.
52314 if(walkable)
20073 {
20074 39775 dy+=1-z3diagskip;
20075 39775 dx+=1-z3diagskip;
20076 39775 z3step=2;
20077 39775 }
20078 else
20079 {
20080 12539 dx+=1-z3diagskip;
20081 12539 z3step=2;
20082 }
20083 52314 }
20084 else
20085 {
20086
2/2
✓ Branch 0 taken 47541 times.
✓ Branch 1 taken 226105 times.
273646 if(walkable)
20087 {
20088 226105 dy+=z3step-z3skip;
20089 226105 z3step=(z3step%2)+1;
20090 226105 }
20091 }
20092
20093 376935 break;
20094
20095 case right:
20096
2/2
✓ Branch 0 taken 592932 times.
✓ Branch 1 taken 69746 times.
662678 if(shiftdir==up)
20097 {
20098
2/2
✓ Branch 0 taken 58004 times.
✓ Branch 1 taken 11742 times.
69746 if(walkable)
20099 {
20100 58004 dy-=1-z3diagskip;
20101 58004 dx+=1-z3diagskip;
20102 58004 z3step=2;
20103 58004 }
20104 else
20105 {
20106 11742 dy-=1-z3diagskip;
20107 11742 z3step=2;
20108 }
20109 69746 }
20110
2/2
✓ Branch 0 taken 54368 times.
✓ Branch 1 taken 538564 times.
592932 else if(shiftdir==down)
20111 {
20112
2/2
✓ Branch 0 taken 45042 times.
✓ Branch 1 taken 9326 times.
54368 if(walkable)
20113 {
20114 45042 dy+=1-z3diagskip;
20115 45042 dx+=1-z3diagskip;
20116 45042 z3step=2;
20117 45042 }
20118 else
20119 {
20120 9326 dy+=1-z3diagskip;
20121 9326 z3step=2;
20122 }
20123 54368 }
20124 else
20125 {
20126
2/2
✓ Branch 0 taken 61923 times.
✓ Branch 1 taken 476641 times.
538564 if(walkable)
20127 {
20128 476641 dx+=z3step-z3skip;
20129 476641 z3step=(z3step%2)+1;
20130 476641 }
20131 }
20132
20133 662678 break;
20134
20135 case left:
20136
2/2
✓ Branch 0 taken 532641 times.
✓ Branch 1 taken 65661 times.
598302 if(shiftdir==up)
20137 {
20138
2/2
✓ Branch 0 taken 55678 times.
✓ Branch 1 taken 9983 times.
65661 if(walkable)
20139 {
20140 55678 dy-=1-z3diagskip;
20141 55678 dx-=1-z3diagskip;
20142 55678 z3step=2;
20143 55678 }
20144 else
20145 {
20146 9983 dy-=1-z3diagskip;
20147 9983 z3step=2;
20148 }
20149 65661 }
20150
2/2
✓ Branch 0 taken 50757 times.
✓ Branch 1 taken 481884 times.
532641 else if(shiftdir==down)
20151 {
20152
2/2
✓ Branch 0 taken 42812 times.
✓ Branch 1 taken 7945 times.
50757 if(walkable)
20153 {
20154 42812 dy+=1-z3diagskip;
20155 42812 dx-=1-z3diagskip;
20156 42812 z3step=2;
20157 42812 }
20158 else
20159 {
20160 7945 dy+=1-z3diagskip;
20161 7945 z3step=2;
20162 }
20163 50757 }
20164 else
20165 {
20166
2/2
✓ Branch 0 taken 50775 times.
✓ Branch 1 taken 431109 times.
481884 if(walkable)
20167 {
20168 431109 dx-=z3step-z3skip;
20169 431109 z3step=(z3step%2)+1;
20170 431109 }
20171 }
20172
20173 598302 break;
20174 }
20175 2084133 }
20176 else
20177 {
20178
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1268161 times.
✓ Branch 2 taken 1035864 times.
✓ Branch 3 taken 1490695 times.
✓ Branch 4 taken 1582924 times.
5377644 switch(d2)
20179 {
20180 case up:
20181
7/14
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 1267853 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 308 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 308 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 308 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 308 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 308 times.
1268161 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy-=ystep;
20182
20183 1268161 break;
20184
20185 case down:
20186
7/14
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1035810 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 54 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 54 times.
1035864 if(!isSideViewHero() || (ladderx && laddery && ladderdir==up) || getOnSideviewLadder() || action == sideswimming || action == sideswimhit || action == sideswimattacking) dy+=ystep;
20187
20188 1035864 break;
20189
20190 case left:
20191 1490695 dx-=xstep;
20192 1490695 break;
20193
20194 case right:
20195 1582924 dx+=xstep;
20196 1582924 break;
20197 }
20198 }
20199 7461777 }
20200
20201
8/16
✓ Branch 0 taken 25815 times.
✓ Branch 1 taken 7436018 times.
✓ Branch 2 taken 7435739 times.
✓ Branch 3 taken 26094 times.
✓ Branch 4 taken 7435470 times.
✓ Branch 5 taken 269 times.
✓ Branch 6 taken 7435470 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 7435470 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
7461833 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
20202 {
20203 7435470 dir=d2;
20204 7435470 }
20205
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 26363 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
26363 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
20206 {
20207 dir = shiftdir;
20208 }
20209
20210
3/4
✓ Branch 0 taken 7360999 times.
✓ Branch 1 taken 100834 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7360999 times.
7461833 if(action != swimming && !IsSideSwim())
20211 {
20212 7360999 herostep();
20213
20214 //ack... don't walk if in midair! -DD
20215
12/14
✓ Branch 0 taken 7335184 times.
✓ Branch 1 taken 25815 times.
✓ Branch 2 taken 7334905 times.
✓ Branch 3 taken 279 times.
✓ Branch 4 taken 7325040 times.
✓ Branch 5 taken 9865 times.
✓ Branch 6 taken 7325040 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 190641 times.
✓ Branch 9 taken 7134399 times.
✓ Branch 10 taken 104043 times.
✓ Branch 11 taken 86598 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 104043 times.
7360999 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
20216 {
20217 7220997 action=walking; FFCore.setHeroAction(walking);
20218 7220997 }
20219
20220
2/2
✓ Branch 0 taken 6967261 times.
✓ Branch 1 taken 393738 times.
7360999 if(++hero_count > (16*hero_animation_speed))
20221 393738 hero_count=0;
20222 7360999 }
20223
2/2
✓ Branch 0 taken 50397 times.
✓ Branch 1 taken 50437 times.
100834 else if(!(frame & 1))
20224 {
20225 50437 herostep();
20226 50437 }
20227
20228
3/4
✓ Branch 0 taken 25815 times.
✓ Branch 1 taken 7436018 times.
✓ Branch 2 taken 25815 times.
✗ Branch 3 not taken.
7461833 if(charging==0 || attack!=wHammer)
20229 {
20230 7461833 sprite::move((zfix)dx,(zfix)dy);
20231 7461833 }
20232 7461833 }
20233 7832512 void HeroClass::moveOld2(int32_t d2, int32_t forceRate)
20234 {
20235
4/6
✓ Branch 0 taken 7829913 times.
✓ Branch 1 taken 2599 times.
✓ Branch 2 taken 7829913 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7829913 times.
7832512 if( inlikelike || lstunclock > 0 || is_conveyor_stunned)
20236 2599 return;
20237
20238
3/4
✓ Branch 0 taken 7461833 times.
✓ Branch 1 taken 368080 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7461833 times.
7829913 if(!get_qr(qr_NEW_HERO_MOVEMENT) && !IsSideSwim())
20239 {
20240 7461833 moveOld(d2);
20241 7461833 return;
20242 }
20243
20244
4/8
✓ Branch 0 taken 9005 times.
✓ Branch 1 taken 359075 times.
✓ Branch 2 taken 9005 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9005 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
727155 bool slowcombo = (combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1) && ((z==0 && fakez==0) || hero_scr->flags2&fAIRCOMBOS)) ||
20245
5/6
✓ Branch 0 taken 2454 times.
✓ Branch 1 taken 356621 times.
✓ Branch 2 taken 1050 times.
✓ Branch 3 taken 1404 times.
✓ Branch 4 taken 2454 times.
✗ Branch 5 not taken.
359075 (isSideViewHero() && (on_sideview_solid_oldpos(this)||getOnSideviewLadder()) && combo_class_buf[combobuf[MAPCOMBO(x+7,y+8)].type].slow_movement && _effectflag(x+7,y+8,1, -1));
20246 //!DIMITODO: add QR for slow combos under hero
20247
4/4
✓ Branch 0 taken 359075 times.
✓ Branch 1 taken 9005 times.
✓ Branch 2 taken 9005 times.
✓ Branch 3 taken 18010 times.
386090 if(slowcombo) for (int32_t i = 1; i <= 2; ++i)
20248 {
20249
2/2
✓ Branch 0 taken 584 times.
✓ Branch 1 taken 17426 times.
18010 if (get_scr_layer_valid(current_screen, i))
20250 {
20251
2/2
✓ Branch 0 taken 11904 times.
✓ Branch 1 taken 5522 times.
17426 if (get_qr(qr_OLD_BRIDGE_COMBOS))
20252 {
20253
2/4
✓ Branch 0 taken 11904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11904 times.
✗ Branch 3 not taken.
11904 if (combobuf[MAPCOMBO2(i-1,x+7,y+8)].type == cBRIDGE && !_walkflag_layer(x+7,y+8))
20254 {
20255 slowcombo = false;
20256 break;
20257 }
20258 11904 }
20259 else
20260 {
20261
2/4
✓ Branch 0 taken 5522 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5522 times.
✗ Branch 3 not taken.
5522 if (combobuf[MAPCOMBO2(i-1,x+7,y+8)].type == cBRIDGE && _effectflag_layer(x+7,y+8))
20262 {
20263 slowcombo = false;
20264 break;
20265 }
20266 }
20267 17426 }
20268 27015 }
20269
2/2
✓ Branch 0 taken 365811 times.
✓ Branch 1 taken 2269 times.
368080 bool slowcharging = charging>0 && (itemsbuf[getWpnPressed(itype_sword)].flags & item_flag10);
20270 368080 bool is_swimming = (action == swimming);
20271 368080 bool fastSwim = (zinit.hero_swim_speed>60);
20272 368080 zfix rate(steprate);
20273 368080 int32_t shieldid = getCurrentActiveShield();
20274
1/2
✓ Branch 0 taken 368080 times.
✗ Branch 1 not taken.
368080 if(shieldid > -1)
20275 {
20276 itemdata const& shield = itemsbuf[shieldid];
20277 if(shield.flags & item_flag10) //Change Speed flag
20278 {
20279 zfix perc = shield.misc7;
20280 perc /= 100;
20281 if(perc < 0)
20282 perc = (perc*-1)+1;
20283 rate = (rate * perc) + shield.misc8;
20284 }
20285 }
20286
20287 368080 zfix dx, dy;
20288 368080 zfix movepix(rate / 100);
20289 368080 zfix step(movepix);
20290 368080 zfix step_diag(movepix);
20291 368080 zfix up_step(game->get_sideswim_up() / -100.0);
20292 368080 zfix left_step(game->get_sideswim_side() / -100.0);
20293 368080 zfix right_step(game->get_sideswim_side() / 100.0);
20294 368080 zfix down_step(game->get_sideswim_down() / 100.0);
20295 368080 bool checkladder = false;
20296
20297
2/2
✓ Branch 0 taken 367877 times.
✓ Branch 1 taken 203 times.
368080 if(hero_newstep > movepix) hero_newstep = movepix;
20298
2/2
✓ Branch 0 taken 367877 times.
✓ Branch 1 taken 203 times.
368080 if(hero_newstep_diag > movepix) hero_newstep_diag = movepix;
20299 //2/3 speed
20300
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 368080 times.
✓ Branch 2 taken 356888 times.
✓ Branch 3 taken 356888 times.
✓ Branch 4 taken 368080 times.
✓ Branch 5 taken 356888 times.
368080 if((is_swimming && fastSwim) || (!is_swimming && (slowcharging ^ slowcombo)))
20301 {
20302 724968 step = ((step / 3.0) * 2);
20303 724968 step_diag = ((step_diag / 3.0) * 2);
20304 724968 up_step = ((up_step / 3.0) * 2);
20305 724968 left_step = ((left_step / 3.0) * 2);
20306 724968 right_step = ((right_step / 3.0) * 2);
20307 724968 down_step = ((down_step / 3.0) * 2);
20308 724968 }
20309 //1/2 speed
20310
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 356888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 31 times.
✓ Branch 5 taken 356857 times.
356888 else if((is_swimming && !fastSwim) || (slowcharging && slowcombo))
20311 {
20312 31 step /= 2;
20313 31 step_diag /= 2;
20314 31 up_step /= 2;
20315 31 left_step /= 2;
20316 31 right_step /= 2;
20317 31 down_step /= 2;
20318 31 }
20319 //normal speed
20320 else
20321 {
20322 //no modification
20323 }
20324
20325
1/2
✓ Branch 0 taken 368080 times.
✗ Branch 1 not taken.
368080 if(diagonalMovement)
20326 {
20327
6/6
✓ Branch 0 taken 290293 times.
✓ Branch 1 taken 77787 times.
✓ Branch 2 taken 311341 times.
✓ Branch 3 taken 21048 times.
✓ Branch 4 taken 136480 times.
✓ Branch 5 taken 252648 times.
560267 if(((d2 == up || d2 == down) && (shiftdir == left || shiftdir == right)) ||
20328
4/4
✓ Branch 0 taken 227037 times.
✓ Branch 1 taken 205989 times.
✓ Branch 2 taken 17618 times.
✓ Branch 3 taken 209419 times.
21048 (d2 == left || d2 == right) && (shiftdir == up || shiftdir == down))
20329 {
20330
3/4
✓ Branch 0 taken 75915 times.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 75915 times.
581315 if(hero_newstep > 0 && hero_newstep_diag > 0)
20331 {
20332 75915 step = STEP_DIAGONAL(step);
20333 75915 step_diag = STEP_DIAGONAL(step_diag);
20334 75915 up_step = STEP_DIAGONAL(up_step);
20335 75915 left_step = STEP_DIAGONAL(left_step);
20336 75915 right_step = STEP_DIAGONAL(right_step);
20337 75915 down_step = STEP_DIAGONAL(down_step);
20338 75915 }
20339 76019 }
20340
2/2
✓ Branch 0 taken 250719 times.
✓ Branch 1 taken 34719 times.
285438 if(hero_newstep < step) step = hero_newstep; //handle collision
20341
2/2
✓ Branch 0 taken 273968 times.
✓ Branch 1 taken 11470 times.
285438 if(hero_newstep_diag < step_diag) step_diag = hero_newstep_diag; //handle collision
20342
5/5
✓ Branch 0 taken 82642 times.
✓ Branch 1 taken 77787 times.
✓ Branch 2 taken 76444 times.
✓ Branch 3 taken 105525 times.
✓ Branch 4 taken 108324 times.
285438 switch(d2)
20343 {
20344 case up:
20345
3/3
✓ Branch 0 taken 61709 times.
✓ Branch 1 taken 7704 times.
✓ Branch 2 taken 8374 times.
77787 switch(shiftdir)
20346 {
20347 case left:
20348 7704 dx = -step_diag;
20349
1/2
✓ Branch 0 taken 7704 times.
✗ Branch 1 not taken.
7704 if (IsSideSwim()) dx = left_step;
20350 7704 break;
20351 case right:
20352 8374 dx = step_diag;
20353
1/2
✓ Branch 0 taken 8374 times.
✗ Branch 1 not taken.
8374 if (IsSideSwim()) dx = right_step;
20354 8374 break;
20355 }
20356
2/2
✓ Branch 0 taken 11035 times.
✓ Branch 1 taken 66752 times.
77787 if(walkable)
20357 {
20358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66752 times.
66752 if (!IsSideSwim()) dy = -step;
20359
1/2
✓ Branch 0 taken 66752 times.
✗ Branch 1 not taken.
66752 if (IsSideSwim())
20360 {
20361 dy = up_step;
20362 if (!iswaterex_z3(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20363 }
20364 66752 }
20365 77787 break;
20366 case down:
20367
3/3
✓ Branch 0 taken 57004 times.
✓ Branch 1 taken 10047 times.
✓ Branch 2 taken 9393 times.
76444 switch(shiftdir)
20368 {
20369 case left:
20370 10047 dx = -step_diag;
20371
1/2
✓ Branch 0 taken 10047 times.
✗ Branch 1 not taken.
10047 if (IsSideSwim()) dx = left_step;
20372 10047 break;
20373 case right:
20374 9393 dx = step_diag;
20375
1/2
✓ Branch 0 taken 9393 times.
✗ Branch 1 not taken.
9393 if (IsSideSwim()) dx = right_step;
20376 9393 break;
20377 }
20378
2/2
✓ Branch 0 taken 8382 times.
✓ Branch 1 taken 68062 times.
76444 if(walkable)
20379 {
20380 68062 dy = step;
20381
1/2
✓ Branch 0 taken 68062 times.
✗ Branch 1 not taken.
68062 if (IsSideSwim()) dy = down_step;
20382 68062 }
20383 76444 break;
20384 case left:
20385
3/3
✓ Branch 0 taken 85010 times.
✓ Branch 1 taken 10934 times.
✓ Branch 2 taken 9581 times.
105525 switch(shiftdir)
20386 {
20387 case up:
20388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10934 times.
10934 if (!IsSideSwim()) dy = -step_diag;
20389
1/2
✓ Branch 0 taken 10934 times.
✗ Branch 1 not taken.
10934 if (IsSideSwim())
20390 {
20391 dy = up_step;
20392 if (!iswaterex_z3(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20393 }
20394 10934 break;
20395 case down:
20396 9581 dy = step_diag;
20397
1/2
✓ Branch 0 taken 9581 times.
✗ Branch 1 not taken.
9581 if (IsSideSwim()) dy = down_step;
20398 9581 break;
20399 }
20400
2/2
✓ Branch 0 taken 9965 times.
✓ Branch 1 taken 95560 times.
105525 if(walkable)
20401 {
20402 95560 dx = -step;
20403
1/2
✓ Branch 0 taken 95560 times.
✗ Branch 1 not taken.
95560 if (IsSideSwim()) dx = left_step;
20404 95560 }
20405 105525 break;
20406 case right:
20407
3/3
✓ Branch 0 taken 88338 times.
✓ Branch 1 taken 10728 times.
✓ Branch 2 taken 9258 times.
108324 switch(shiftdir)
20408 {
20409 case up:
20410
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10728 times.
10728 if (!IsSideSwim()) dy = -step_diag;
20411
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if (IsSideSwim())
20412 {
20413 dy = up_step;
20414 if (!iswaterex_z3(MAPCOMBO(x,y+8-(bigHitbox*8)+floor(up_step)), -1, x, y+8-(bigHitbox*8)-2, true, false)) checkladder = true;
20415 }
20416 10728 break;
20417 case down:
20418 9258 dy = step_diag;
20419
1/2
✓ Branch 0 taken 9258 times.
✗ Branch 1 not taken.
9258 if (IsSideSwim()) dy = down_step;
20420 9258 break;
20421 }
20422
2/2
✓ Branch 0 taken 10374 times.
✓ Branch 1 taken 97950 times.
108324 if(walkable)
20423 {
20424 97950 dx = step;
20425
1/2
✓ Branch 0 taken 97950 times.
✗ Branch 1 not taken.
97950 if (IsSideSwim()) dx = right_step;
20426 97950 }
20427 108324 break;
20428 };
20429 450722 }
20430 else
20431 {
20432 if(hero_newstep < step) step = hero_newstep; //handle collision
20433 switch(d2)
20434 {
20435 case up:
20436 dy -= step;
20437 if (IsSideSwim()) dy = up_step;
20438 break;
20439 case down:
20440 dy += step;
20441 if (IsSideSwim()) dy = down_step;
20442 break;
20443 case left:
20444 dx -= step;
20445 if (IsSideSwim()) dx = left_step;
20446 break;
20447 case right:
20448 dx += step;
20449 if (IsSideSwim()) dx = right_step;
20450 break;
20451 };
20452 }
20453 450722 hero_newstep = movepix;
20454 450722 hero_newstep_diag = movepix;
20455
20456
7/16
✓ Branch 0 taken 2269 times.
✓ Branch 1 taken 448453 times.
✓ Branch 2 taken 365811 times.
✓ Branch 3 taken 84911 times.
✓ Branch 4 taken 365811 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 365811 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 365811 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
450722 if((charging==0 || attack==wHammer) && spins==0 && attackclk!=HAMMERCHARGEFRAME && action != sideswimattacking && !(IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down))) //!DIRECTION SET
20457 {
20458 365811 dir=d2;
20459 365811 }
20460
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 84911 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
84911 else if (IsSideSwim() && get_qr(qr_SIDESWIMDIR) && (d2 == up || d2 == down) && (shiftdir == left || shiftdir == right) && (charging==0 && spins==0))
20461 {
20462 dir = shiftdir;
20463 }
20464
2/2
✓ Branch 0 taken 450465 times.
✓ Branch 1 taken 257 times.
450722 if(forceRate > -1)
20465 {
20466 257 checkladder = false;
20467
2/3
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 245 times.
257 switch(dir)
20468 {
20469 case right:
20470 case r_up:
20471 case r_down:
20472 12 dx = zfix(forceRate) / 100;
20473 12 break;
20474 case left:
20475 case l_up:
20476 case l_down:
20477 dx = zfix(-forceRate) / 100;
20478 break;
20479 default:
20480 245 dx = 0;
20481 245 }
20482
3/3
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 228 times.
✓ Branch 2 taken 12 times.
257 switch(dir)
20483 {
20484 case down:
20485 case r_down:
20486 case l_down:
20487 17 dy = zfix(forceRate) / 100;
20488 17 break;
20489 case up:
20490 case r_up:
20491 case l_up:
20492 228 dy = zfix(-forceRate) / 100;
20493 228 break;
20494 default:
20495 12 dy = 0;
20496 12 }
20497 257 }
20498
4/4
✓ Branch 0 taken 2454 times.
✓ Branch 1 taken 448268 times.
✓ Branch 2 taken 1716 times.
✓ Branch 3 taken 738 times.
450722 if (isSideViewHero() && slopeid)
20499 {
20500 738 dy += (dx * slopeid);
20501 738 }
20502
4/4
✓ Branch 0 taken 139312 times.
✓ Branch 1 taken 311410 times.
✓ Branch 2 taken 111086 times.
✓ Branch 3 taken 28226 times.
450722 if(dx == 0 && dy == 0) return;
20503
5/8
✓ Branch 0 taken 339854 times.
✓ Branch 1 taken 82642 times.
✓ Branch 2 taken 339854 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 339854 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 339854 times.
422496 if(action != swimming && action != sideswimming && action != sideswimhit && action != sideswimattacking)
20504 {
20505 339854 herostep();
20506
20507 //ack... don't walk if in midair! -DD
20508
11/14
✓ Branch 0 taken 337851 times.
✓ Branch 1 taken 2003 times.
✓ Branch 2 taken 337851 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 335538 times.
✓ Branch 5 taken 2313 times.
✓ Branch 6 taken 335538 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2390 times.
✓ Branch 9 taken 333148 times.
✓ Branch 10 taken 1016 times.
✓ Branch 11 taken 1374 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 1016 times.
339854 if(charging==0 && spins==0 && z==0 && fakez==0 && !(isSideViewHero() && !on_sideview_solid_oldpos(this) && !getOnSideviewLadder()))
20509 {
20510 334522 action=walking; FFCore.setHeroAction(walking);
20511 334522 }
20512
20513
2/2
✓ Branch 0 taken 321950 times.
✓ Branch 1 taken 17904 times.
339854 if(++hero_count > (16*hero_animation_speed))
20514 17904 hero_count=0;
20515 339854 }
20516
1/2
✓ Branch 0 taken 82642 times.
✗ Branch 1 not taken.
82642 else if(!(frame & 1))
20517 {
20518 herostep();
20519 }
20520
20521
4/4
✓ Branch 0 taken 2003 times.
✓ Branch 1 taken 420493 times.
✓ Branch 2 taken 80639 times.
✓ Branch 3 taken 78636 times.
422496 if(charging==0 || attack!=wHammer)
20522 {
20523 501132 sprite::move(dx, dy);
20524 501132 WalkflagInfo info;
20525 501132 info = walkflag(x,y+8-(bigHitbox*8)-4,2,up);
20526 501132 execute(info);
20527
2/8
✗ Branch 0 not taken.
✓ Branch 1 taken 339854 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 339854 times.
✗ Branch 7 not taken.
501132 if (checkladder && !canSideviewLadderRemote(x, y-4) && !info.isUnwalkable() && (y + 8 - (bigHitbox * 8) - 4) > 0)
20528 {
20529 if (game->get_sideswim_jump() != 0)
20530 {
20531 setFall(zfix(0-(FEATHERJUMP*(game->get_sideswim_jump()/10000.0))));
20532 sfx(WAV_ZN1SPLASH,(int32_t)x);
20533 hopclk = 0;
20534 if (charging || spins) action = attacking;
20535 else action = none;
20536 }
20537 else
20538 {
20539 sprite::move(0_zf, zfix(-1*dy));
20540 }
20541 }
20542 339854 }
20543 7911148 }
20544
20545 void HeroClass::start_auto_walk(const combined_handle_t& target)
20546 {
20547 auto& cmb = target.combo();
20548 if(cmb.type != cCUTSCENEEFFECT || cmb.attribytes[0] != CUTEFF_PLAYER_WALK) return;
20549
20550 zfix dx = zslongToFix(cmb.attributes[0]), dy = zslongToFix(cmb.attributes[1]);
20551 if(cmb.usrflags & cflag1)
20552 {
20553 auto [cx, cy] = target.center_xy();
20554 dx += cx-8;
20555 dy += cy-8;
20556 }
20557 else if(cmb.usrflags & cflag2)
20558 {
20559 dx += x;
20560 dy += y;
20561 }
20562
20563 reset_hookshot();
20564
20565 autowalk_dest_x = dx;
20566 autowalk_dest_y = dy;
20567 autowalk_combo_id = target.data();
20568 autowalk_handle = target;
20569 }
20570 37234 void HeroClass::finish_auto_walk()
20571 {
20572
1/2
✓ Branch 0 taken 37234 times.
✗ Branch 1 not taken.
37234 if(!autowalk_handle) return;
20573
20574 if(autowalk_combo_id >= 0 && autowalk_handle.data() == autowalk_combo_id)
20575 {
20576 auto& cmb = autowalk_handle.combo();
20577 if(cmb.type == cCUTSCENEEFFECT && cmb.attribytes[0] == CUTEFF_PLAYER_WALK)
20578 do_trigger_ctype_causes(autowalk_handle);
20579 }
20580 autowalk_handle = rpos_handle_t();
20581 autowalk_combo_id = -1;
20582 autowalk_dest_x = autowalk_dest_y = 0;
20583 37234 }
20584
20585 void HeroClass::autowalk_move()
20586 {
20587 if(x == autowalk_dest_x && y == autowalk_dest_y) // reached destination already
20588 {
20589 finish_auto_walk();
20590 return;
20591 }
20592
20593 zfix pix_dist;
20594 if(autowalk_combo_id > -1)
20595 {
20596 newcombo const& cmb = combobuf[autowalk_combo_id];
20597 if(cmb.type == cCUTSCENEEFFECT && cmb.attribytes[0] == CUTEFF_PLAYER_WALK)
20598 {
20599 if(cmb.attributes[2])
20600 pix_dist = zslongToFix(cmb.attributes[2]);
20601 }
20602 }
20603 if(!pix_dist)
20604 {
20605 pix_dist = steprate / 100_zf;
20606 vector<zfix*> vec = { &pix_dist };
20607 mod_steps(vec);
20608 if(!pix_dist) // ensure not stuck
20609 pix_dist = 1;
20610 }
20611
20612 // -1, 0, or 1
20613 int dir_x = (autowalk_dest_x > x) - (autowalk_dest_x < x);
20614 int dir_y = (autowalk_dest_y > y) - (autowalk_dest_y < y);
20615
20616 double _MSVC2022_tmp1, _MSVC2022_tmp2;
20617 double angle = atan2_MSVC2022_FIX(double(autowalk_dest_y-y),double(autowalk_dest_x-x));
20618 zfix dx, dy;
20619 if(x != autowalk_dest_x)
20620 dx = zc::math::Cos(angle)*pix_dist;
20621 if(y != autowalk_dest_y)
20622 dy = zc::math::Sin(angle)*pix_dist;
20623
20624 zfix cur_dest_x = x+dx, cur_dest_y = y+dy;
20625 // check if this move will reach or pass the destination, and make it land exactly on the destination instead
20626 if(dir_x != ((autowalk_dest_x > cur_dest_x) - (autowalk_dest_x < cur_dest_x)))
20627 {
20628 cur_dest_x = autowalk_dest_x;
20629 dx = cur_dest_x - x;
20630 }
20631 if(dir_y != ((autowalk_dest_y > cur_dest_y) - (autowalk_dest_y < cur_dest_y)))
20632 {
20633 cur_dest_y = autowalk_dest_y;
20634 dy = cur_dest_y - y;
20635 }
20636
20637 movexy(dx, dy, false, true, false, true); // try to move for purposes such as the ladder
20638 x = cur_dest_x; y = cur_dest_y; // ... but just set the x/y to be sure nothing got in the way
20639
20640 if(dx || dy)
20641 {
20642 if(abs(dx) > abs(dy))
20643 {
20644 if(dx < 0) dir = left;
20645 else dir = right;
20646 }
20647 else
20648 {
20649 if(dy < 0) dir = up;
20650 else dir = down;
20651 }
20652 }
20653
20654 if(x == autowalk_dest_x && y == autowalk_dest_y) // reached destination
20655 finish_auto_walk();
20656 }
20657
20658 376711984 bool HeroClass::is_autowalking() const
20659 {
20660 376711984 return autowalk_combo_id >= 0;
20661 }
20662 281363302 bool HeroClass::no_control() const
20663 {
20664 281363302 return is_autowalking(); // can possibly add other stuff here later, like maybe a script bool?
20665 }
20666 32524807 HeroClass::WalkflagInfo HeroClass::walkflag(zfix fx,zfix fy,int32_t cnt,byte d2)
20667 {
20668 32524807 return walkflag(fx.getInt(), fy.getInt(), cnt, d2);
20669 }
20670 32524807 HeroClass::WalkflagInfo HeroClass::walkflag(int32_t wx,int32_t wy,int32_t cnt,byte d2)
20671 {
20672 32524807 WalkflagInfo ret;
20673
20674
2/2
✓ Branch 0 taken 189113 times.
✓ Branch 1 taken 32335694 times.
32524807 if (!is_in_world_bounds(wx, wy))
20675 {
20676 189113 ret.setUnwalkable(false);
20677 189113 return ret;
20678 }
20679
20680
2/2
✓ Branch 0 taken 45484 times.
✓ Branch 1 taken 32290210 times.
32335694 if(toogam)
20681 {
20682 45484 ret.setUnwalkable(false);
20683 45484 return ret;
20684 }
20685
20686
4/4
✓ Branch 0 taken 547849 times.
✓ Branch 1 taken 31742361 times.
✓ Branch 2 taken 522813 times.
✓ Branch 3 taken 25036 times.
32290210 if(blockpath && wy<(bigHitbox?80:88))
20687 {
20688 25036 ret.setUnwalkable(true);
20689 25036 return ret;
20690 }
20691
20692
4/4
✓ Branch 0 taken 507805 times.
✓ Branch 1 taken 31757369 times.
✓ Branch 2 taken 317946 times.
✓ Branch 3 taken 189859 times.
32265174 if(mblock2.active() && mblock2.hit(wx,wy,0,1,1,1))
20693 {
20694 189859 ret.setUnwalkable(true);
20695 189859 return ret;
20696 }
20697
20698
2/2
✓ Branch 0 taken 1100 times.
✓ Branch 1 taken 32074215 times.
32075315 if (collide_object(wx, wy,1, 1))
20699 {
20700 1100 ret.setUnwalkable(true);
20701 1100 return ret;
20702 }
20703
20704
18/22
✓ Branch 0 taken 15316175 times.
✓ Branch 1 taken 16758040 times.
✓ Branch 2 taken 14864682 times.
✓ Branch 3 taken 451493 times.
✓ Branch 4 taken 14343660 times.
✓ Branch 5 taken 521022 times.
✓ Branch 6 taken 517624 times.
✓ Branch 7 taken 3398 times.
✓ Branch 8 taken 517624 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 517624 times.
✓ Branch 12 taken 2095 times.
✓ Branch 13 taken 1303 times.
✓ Branch 14 taken 281863 times.
✓ Branch 15 taken 239159 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 239159 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 239159 times.
✓ Branch 20 taken 31083 times.
✓ Branch 21 taken 32043132 times.
32386520 if(isdungeon() && cur_screen<128 && wy<(bigHitbox?32:40) && (((diagonalMovement||NO_GRIDLOCK)?(x<=112||x>=128):x!=120) || _walkflag(120,24,2,STANDING_Z_STATE))
20705
2/2
✓ Branch 0 taken 30442 times.
✓ Branch 1 taken 208717 times.
521022 && !get_qr(qr_FREEFORM))
20706 {
20707 31083 ret.setUnwalkable(true);
20708 31083 return ret;
20709 }
20710
20711
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32043132 times.
✓ Branch 2 taken 32043132 times.
✗ Branch 3 not taken.
32043132 bool wf = _walkflag(wx,wy,cnt,STANDING_Z_STATE);
20712
20713
6/6
✓ Branch 0 taken 15285092 times.
✓ Branch 1 taken 16758040 times.
✓ Branch 2 taken 14833599 times.
✓ Branch 3 taken 451493 times.
✓ Branch 4 taken 6357215 times.
✓ Branch 5 taken 8476384 times.
32043132 if(isdungeon() && cur_screen<128 && !get_qr(qr_FREEFORM))
20714 {
20715
3/6
✓ Branch 0 taken 8476384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8476384 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8476384 times.
8476384 if((diagonalMovement||NO_GRIDLOCK))
20716 {
20717 if(wx>=112&&wx<120&&wy<40&&wy>=32) wf=true;
20718
20719 if(wx>=136&&wx<144&&wy<40&&wy>=32) wf=true;
20720 }
20721 8476384 }
20722 //All problems related to exiting water are probably here. -Z
20723
3/4
✓ Branch 0 taken 31365802 times.
✓ Branch 1 taken 677330 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31365802 times.
32043132 if(action==swimming || IsSideSwim())
20724 {
20725
2/2
✓ Branch 0 taken 645181 times.
✓ Branch 1 taken 32149 times.
677330 if(!wf)
20726 {
20727 32149 bool isthissolid = false;
20728
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 32149 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32149 times.
✓ Branch 4 taken 5887 times.
✓ Branch 5 taken 26262 times.
38460 if (_walkflag(x+7,y+(bigHitbox?6:11),1,STANDING_Z_STATE)
20729
4/6
✓ Branch 0 taken 25838 times.
✓ Branch 1 taken 6311 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6311 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6311 times.
32149 || _walkflag(x+7,y+(bigHitbox?9:12),1,STANDING_Z_STATE)
20730
4/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 6289 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6289 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6289 times.
6311 || _walkflag(x+8,y+(bigHitbox?6:11),1,STANDING_Z_STATE)
20731
4/6
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 5887 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5887 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5887 times.
32551 || _walkflag(x+8,y+(bigHitbox?9:12),1,STANDING_Z_STATE)) isthissolid = true;
20732 //This checks if Hero is currently swimming in solid water (cause even if the QR "No Hopping" is enabled, he should still hop out of solid water) - Dimi
20733
20734
20735
5/6
✓ Branch 0 taken 7310 times.
✓ Branch 1 taken 24839 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7310 times.
✓ Branch 4 taken 14729 times.
✓ Branch 5 taken 46086 times.
56988 if(landswim>= (get_qr(qr_DROWN) && isSwimming() ? 1
20736
2/2
✓ Branch 0 taken 2107 times.
✓ Branch 1 taken 22732 times.
24839 : (!diagonalMovement) ? 1 : (get_qr(qr_NO_HOPPING)?1:22)))
20737 {
20738 //Check for out of bounds for swimming
20739 14729 bool changehop = true;
20740
20741
5/6
✓ Branch 0 taken 1828 times.
✓ Branch 1 taken 12901 times.
✓ Branch 2 taken 1828 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12828 times.
✓ Branch 5 taken 11732 times.
14729 if((diagonalMovement||NO_GRIDLOCK))
20742 {
20743
2/4
✓ Branch 0 taken 73 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 73 times.
25729 if(wx<0||wy<0)
20744 changehop = false;
20745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
73 else if(wx>world_w - 8)
20746 changehop = false;
20747
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
73 else if(wx>world_w - 16&&cnt==2)
20748 changehop = false;
20749
2/2
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 3 times.
73 else if(wy>world_h - (show_bottom_8px ? 0 : 8))
20750 3 changehop = false;
20751 73 }
20752
3/4
✓ Branch 0 taken 1901 times.
✓ Branch 1 taken 9904 times.
✓ Branch 2 taken 11805 times.
✗ Branch 3 not taken.
11805 if ((get_qr(qr_NO_HOPPING) || CanSideSwim()) && !isthissolid) changehop = false;
20753 //This may be where the hang-up for exiting water exists. -Z
20754 // hop out of the water
20755
2/2
✓ Branch 0 taken 9907 times.
✓ Branch 1 taken 1898 times.
11805 if(changehop)
20756 1898 ret.setHopClk(1);
20757 11805 }
20758 else
20759 {
20760
6/6
✓ Branch 0 taken 26109 times.
✓ Branch 1 taken 19977 times.
✓ Branch 2 taken 25289 times.
✓ Branch 3 taken 20797 times.
✓ Branch 4 taken 16813 times.
✓ Branch 5 taken 8476 times.
46086 if((!(get_qr(qr_NO_HOPPING) || CanSideSwim()) || isthissolid) && (dir==d2 || shiftdir==d2))
20761 {
20762
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 7515 times.
25289 if(d2==left)
20763 {
20764
4/4
✓ Branch 0 taken 1660 times.
✓ Branch 1 taken 276 times.
✓ Branch 2 taken 1656 times.
✓ Branch 3 taken 280 times.
3596 if(!iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?6:11)), -1, x-1,y+(bigHitbox?6:11)) &&
20765
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1658 times.
1660 !iswaterex_z3(MAPCOMBO(x-1,y+(bigHitbox?9:12)), -1, x-1,y+(bigHitbox?9:12)) &&
20766
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1658 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1658 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 1656 times.
1658 !_walkflag(x-1,y+(bigHitbox?6:11),1,STANDING_Z_STATE) &&
20767
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1656 times.
1656 !_walkflag(x-1,y+(bigHitbox?9:12),1,STANDING_Z_STATE))
20768 {
20769 1656 ret.setHopDir(d2);
20770 1656 ret.setIlswim(true);
20771 1656 }
20772 280 else ret.setIlswim(false);
20773 1936 }
20774
2/2
✓ Branch 0 taken 5751 times.
✓ Branch 1 taken 1764 times.
7515 else if(d2==right)
20775 {
20776
4/4
✓ Branch 0 taken 1654 times.
✓ Branch 1 taken 4097 times.
✓ Branch 2 taken 1654 times.
✓ Branch 3 taken 4097 times.
7405 if(!iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?6:11)), -1, x+16,y+(bigHitbox?6:11)) &&
20777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
1654 !iswaterex_z3(MAPCOMBO(x+16,y+(bigHitbox?9:12)), -1, x+16,y+(bigHitbox?9:12)) &&
20778
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1654 times.
1654 !_walkflag(x+16,y+(bigHitbox?6:11),1,STANDING_Z_STATE) &&
20779
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1654 times.
1654 !_walkflag(x+16,y+(bigHitbox?9:12),1,STANDING_Z_STATE))
20780 {
20781 1654 ret.setHopDir(d2);
20782 1654 ret.setIlswim(true);
20783 1654 }
20784 4097 else ret.setIlswim(false);
20785 5751 }
20786
2/2
✓ Branch 0 taken 1002 times.
✓ Branch 1 taken 762 times.
1764 else if(d2==up)
20787 {
20788
4/4
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 221 times.
✓ Branch 2 taken 539 times.
✓ Branch 3 taken 223 times.
1303 if(!iswaterex_z3(MAPCOMBO(x+7,y+(bigHitbox?0:8)-1), -1, x+7,y+(bigHitbox?0:8)-1) &&
20789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 541 times.
541 !iswaterex_z3(MAPCOMBO(x+8,y+(bigHitbox?0:8)-1), -1, x+8,y+(bigHitbox?0:8)-1) &&
20790
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 541 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 541 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 539 times.
541 !_walkflag(x+7,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE) &&
20791
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 539 times.
539 !_walkflag(x+8,y+(bigHitbox?0:8)-1,1,STANDING_Z_STATE))
20792 {
20793 539 ret.setHopDir(d2);
20794 539 ret.setIlswim(true);
20795 539 }
20796 223 else ret.setIlswim(false);
20797 762 }
20798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1002 times.
1002 else if(d2==down)
20799 {
20800
4/4
✓ Branch 0 taken 351 times.
✓ Branch 1 taken 651 times.
✓ Branch 2 taken 351 times.
✓ Branch 3 taken 651 times.
1353 if(!iswaterex_z3(MAPCOMBO(x+7,y+16), -1, x+7,y+16) &&
20801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
351 !iswaterex_z3(MAPCOMBO(x+8,y+16), -1, x+8,y+16) &&
20802
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 351 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 351 times.
351 !_walkflag(x+7,y+16,1,STANDING_Z_STATE) &&
20803
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 351 times.
✗ Branch 3 not taken.
351 !_walkflag(x+8,y+16,1,STANDING_Z_STATE))
20804 {
20805 351 ret.setHopDir(d2);
20806 351 ret.setIlswim(true);
20807 351 }
20808 651 else ret.setIlswim(false);
20809 1002 }
20810 9451 }
20811
20812
2/4
✓ Branch 0 taken 30248 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 30248 times.
30248 if(wx<0||wy<0);
20813
2/2
✓ Branch 0 taken 4422 times.
✓ Branch 1 taken 25826 times.
30248 else if(wx > world_w - 8);
20814
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25826 else if(wx > world_w - 16 &&cnt==2);
20815
2/2
✓ Branch 0 taken 774 times.
✓ Branch 1 taken 25052 times.
25826 else if(wy > world_h - (show_bottom_8px ? 0 : 8));
20816
4/4
✓ Branch 0 taken 6428 times.
✓ Branch 1 taken 18624 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 6399 times.
25052 else if(get_qr(qr_DROWN) && !ilswim);
20817
2/2
✓ Branch 0 taken 17095 times.
✓ Branch 1 taken 1558 times.
18653 else if(iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy)) //!DIMI: weird duplicate function here before. Was water bugged this whole time, or was it just an unneccessary duplicate?
20818 {
20819 1558 ret.setUnwalkable(false);
20820 1558 return ret;
20821 }
20822 else
20823 {
20824 17095 ret.setUnwalkable(true);
20825 17095 return ret;
20826 }
20827 }
20828 23400 }
20829 else
20830 {
20831
4/4
✓ Branch 0 taken 595014 times.
✓ Branch 1 taken 50167 times.
✓ Branch 2 taken 56527 times.
✓ Branch 3 taken 538487 times.
645181 if (d2>=left && iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy))
20832 {
20833 538487 ret.setUnwalkable(false);
20834 538487 return ret;
20835 }
20836
6/6
✓ Branch 0 taken 50167 times.
✓ Branch 1 taken 56527 times.
✓ Branch 2 taken 10796 times.
✓ Branch 3 taken 39371 times.
✓ Branch 4 taken 38171 times.
✓ Branch 5 taken 68523 times.
106694 else if (d2<=down && iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy) && iswaterex_z3(MAPCOMBO(x+8,wy), -1, x+8,wy))
20837 {
20838 38171 ret.setUnwalkable(false);
20839 38171 return ret;
20840 }
20841 }
20842 91923 }
20843
2/2
✓ Branch 0 taken 384504 times.
✓ Branch 1 taken 30981298 times.
31365802 else if(ladderx+laddery) // ladder is being used
20844 {
20845
8/10
✓ Branch 0 taken 27069 times.
✓ Branch 1 taken 357435 times.
✓ Branch 2 taken 25080 times.
✓ Branch 3 taken 1989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
✓ Branch 6 taken 1989 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1936 times.
✓ Branch 9 taken 53 times.
384504 int32_t lx = !(get_qr(qr_DROWN)&&iswaterex_z3(MAPCOMBO(x+4,y+11), -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,STANDING_Z_STATE)) ? zfix(wx) : x;
20846
8/10
✓ Branch 0 taken 27069 times.
✓ Branch 1 taken 357435 times.
✓ Branch 2 taken 25080 times.
✓ Branch 3 taken 1989 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1989 times.
✓ Branch 6 taken 1989 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1936 times.
✓ Branch 9 taken 53 times.
384504 int32_t ly = !(get_qr(qr_DROWN)&&iswaterex_z3(MAPCOMBO(x+4,y+11), -1, x+4,y+11)&&!_walkflag(x+4,y+11,1,STANDING_Z_STATE)) ? zfix(wy) : y;
20847
20848
4/6
✓ Branch 0 taken 363296 times.
✓ Branch 1 taken 21208 times.
✓ Branch 2 taken 363296 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 363296 times.
384504 if((diagonalMovement||NO_GRIDLOCK))
20849 {
20850
2/2
✓ Branch 0 taken 13575 times.
✓ Branch 1 taken 7633 times.
21208 if(ladderdir==up)
20851 {
20852
2/2
✓ Branch 0 taken 3363 times.
✓ Branch 1 taken 4270 times.
7633 if(abs(ly-(laddery+8))<=8) // ly is between laddery (laddery+8-8) and laddery+16 (laddery+8+8)
20853 {
20854 4270 bool temp = false;
20855
20856
2/2
✓ Branch 0 taken 1391 times.
✓ Branch 1 taken 2879 times.
4270 if(!(abs(lx-(ladderx+8))<=8))
20857 2879 temp = true;
20858
20859
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 980 times.
4270 if(cnt==2)
20860
1/2
✓ Branch 0 taken 980 times.
✗ Branch 1 not taken.
980 if(!(abs((lx+8)-(ladderx+8))<=8))
20861 temp=true;
20862
20863
2/2
✓ Branch 0 taken 2879 times.
✓ Branch 1 taken 1391 times.
4270 if(!temp)
20864 {
20865 1391 ret.setUnwalkable(false);
20866 1391 return ret;
20867 }
20868
20869
5/6
✓ Branch 0 taken 2879 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2125 times.
✓ Branch 3 taken 754 times.
✓ Branch 4 taken 122 times.
✓ Branch 5 taken 2757 times.
2879 if(current_item_power(itype_ladder)<2 && (d2==left || d2==right) && !isSideViewHero())
20870 {
20871 2757 ret.setUnwalkable(true);
20872 2757 return ret;
20873 }
20874 122 }
20875 3485 }
20876 else
20877 {
20878
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 6555 times.
13575 if(abs(lx-(ladderx+8))<=8)
20879 {
20880
2/2
✓ Branch 0 taken 4323 times.
✓ Branch 1 taken 2232 times.
6555 if(abs(ly-(laddery+(bigHitbox?8:12)))<=(bigHitbox?8:4))
20881 {
20882 4323 ret.setUnwalkable(false);
20883 4323 return ret;
20884 }
20885
20886
6/6
✓ Branch 0 taken 2220 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 1785 times.
✓ Branch 3 taken 435 times.
✓ Branch 4 taken 916 times.
✓ Branch 5 taken 869 times.
2232 if(current_item_power(itype_ladder)<2 && (d2==up || d2==down))
20887 {
20888 1351 ret.setUnwalkable(true);
20889 1351 return ret;
20890 }
20891
20892
3/4
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
881 if((abs(ly-laddery+8)<=8) && d2<=down)
20893 {
20894 ret.setUnwalkable(false);
20895 return ret;
20896 }
20897 881 }
20898 }
20899 11386 } // diagonalMovement
20900 else
20901 {
20902
2/2
✓ Branch 0 taken 222358 times.
✓ Branch 1 taken 140938 times.
363296 if((d2&2)==ladderdir) // same direction
20903 {
20904
3/3
✓ Branch 0 taken 13729 times.
✓ Branch 1 taken 196539 times.
✓ Branch 2 taken 12090 times.
222358 switch(d2)
20905 {
20906 case up:
20907
2/2
✓ Branch 0 taken 8605 times.
✓ Branch 1 taken 3485 times.
12090 if(y.getInt()<=laddery)
20908 {
20909
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8605 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8605 times.
✓ Branch 4 taken 970 times.
✓ Branch 5 taken 7635 times.
16240 ret.setUnwalkable(_walkflag(ladderx,laddery-8,1,STANDING_Z_STATE) ||
20910
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7635 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7635 times.
7635 _walkflag(ladderx+8,laddery-8,1,STANDING_Z_STATE));
20911 8605 return ret;
20912
20913 }
20914
20915 [[fallthrough]];
20916 case down:
20917
2/2
✓ Branch 0 taken 9176 times.
✓ Branch 1 taken 8038 times.
17214 if(TRUNCATE_TILE(wy)==laddery)
20918 {
20919 9176 ret.setUnwalkable(false);
20920 9176 return ret;
20921 }
20922
20923 8038 break;
20924
20925 default:
20926
2/2
✓ Branch 0 taken 74354 times.
✓ Branch 1 taken 122185 times.
196539 if(TRUNCATE_TILE(wx)==ladderx)
20927 {
20928 74354 ret.setUnwalkable(false);
20929 74354 return ret;
20930 }
20931 122185 }
20932
20933
2/2
✓ Branch 0 taken 8038 times.
✓ Branch 1 taken 122185 times.
130223 if(d2<=down)
20934 {
20935
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 8038 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8038 times.
✓ Branch 4 taken 1060 times.
✓ Branch 5 taken 6978 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 6978 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 6978 times.
8038 ret.setUnwalkable(_walkflag(ladderx,wy,1,STANDING_Z_STATE) || _walkflag(ladderx+8,wy,1,STANDING_Z_STATE));
20936 8038 return ret;
20937 }
20938
20939
6/10
✗ Branch 0 not taken.
✓ Branch 1 taken 122185 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 122185 times.
✓ Branch 4 taken 29654 times.
✓ Branch 5 taken 92531 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 92531 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 92531 times.
122185 ret.setUnwalkable(_walkflag(TRUNCATE_TILE(wx),wy,1,STANDING_Z_STATE) || _walkflag(TRUNCATE_TILE(wx)+8,wy,1,STANDING_Z_STATE));
20940 122185 return ret;
20941 }
20942
20943 // different dir
20944
3/8
✓ Branch 0 taken 140509 times.
✓ Branch 1 taken 429 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 140509 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
140938 if(current_item_power(itype_ladder)<2 && !(isSideViewHero() && (d2==left || d2==right)))
20945 {
20946 140509 ret.setUnwalkable(true);
20947 140509 return ret;
20948 }
20949
20950
5/6
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 372 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 352 times.
✓ Branch 5 taken 20 times.
429 if(wy>=laddery && wy<=laddery+16 && d2<=down)
20951 {
20952 20 ret.setUnwalkable(false);
20953 20 return ret;
20954 }
20955 }
20956 11795 }
20957
6/6
✓ Branch 0 taken 25667495 times.
✓ Branch 1 taken 5313803 times.
✓ Branch 2 taken 25284049 times.
✓ Branch 3 taken 383446 times.
✓ Branch 4 taken 6699086 times.
✓ Branch 5 taken 18584963 times.
30981298 else if(wf || isSideViewHero() || get_qr(qr_DROWN))
20958 {
20959 // see if it's a good spot for the ladder or for swimming
20960
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12396335 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12396335 times.
12396335 bool unwalkablex = _walkflag(wx,wy,1,STANDING_Z_STATE); //will be used later for the ladder -DD
20961
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12396335 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12396335 times.
12396335 bool unwalkablex8 = _walkflag(x+8,wy,1,STANDING_Z_STATE);
20962
20963
2/2
✓ Branch 0 taken 3562450 times.
✓ Branch 1 taken 8833885 times.
12396335 if(get_qr(qr_DROWN))
20964 {
20965 // Drowning changes the following attributes:
20966 // * Dangerous water is also walkable, so ignore the previous
20967 // definitions of unwalkablex and unwalkablex8.
20968 // * Instead, prevent the ladder from being used in the
20969 // one frame where Hero has landed on water before drowning.
20970 8833885 unwalkablex = unwalkablex8 = !iswaterex_z3(MAPCOMBO(x+4,y+11), -1, x+4,y+11);
20971 8833885 }
20972
20973 // check if he can swim
20974
5/6
✓ Branch 0 taken 2582531 times.
✓ Branch 1 taken 9813804 times.
✓ Branch 2 taken 2579567 times.
✓ Branch 3 taken 2964 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2579567 times.
12396335 if(current_item(itype_flippers) && z==0 && fakez==0)
20975 {
20976 2579567 int32_t wtrx = iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy);
20977 2579567 int32_t wtrx8 = iswaterex_z3(MAPCOMBO(x+8,wy), -1, x+8,wy); //!DIMI: Still not sure if this should be x + 8...
20978
2/6
✓ Branch 0 taken 2579567 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2579567 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2579567 if (current_item(itype_flippers) >= combobuf[wtrx8].attribytes[0] && (!(combobuf[wtrx8].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))) //Don't swim if the water's required level is too high! -Dimi
20979 {
20980 //ladder ignores water combos that are now walkable thanks to flippers -DD
20981
2/2
✓ Branch 0 taken 13116 times.
✓ Branch 1 taken 2566451 times.
2579567 unwalkablex = unwalkablex && (!wtrx);
20982
2/2
✓ Branch 0 taken 1358908 times.
✓ Branch 1 taken 1220659 times.
2579567 unwalkablex8 = unwalkablex8 && (!wtrx8);
20983
20984
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 2579505 times.
2579567 if(landswim >= 22)
20985 {
20986 62 ret.setHopClk(2);
20987 62 ret.setUnwalkable(false);
20988 62 return ret;
20989 }
20990
8/8
✓ Branch 0 taken 2202699 times.
✓ Branch 1 taken 376806 times.
✓ Branch 2 taken 17578 times.
✓ Branch 3 taken 2185121 times.
✓ Branch 4 taken 376806 times.
✓ Branch 5 taken 2185121 times.
✓ Branch 6 taken 1912 times.
✓ Branch 7 taken 374894 times.
2579505 else if((d2>=left && wtrx) || (d2<=down && wtrx && wtrx8))
20991 {
20992
4/6
✓ Branch 0 taken 12538 times.
✓ Branch 1 taken 6952 times.
✓ Branch 2 taken 12538 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12538 times.
19490 if(!(diagonalMovement||NO_GRIDLOCK))
20993 {
20994 12538 ret.setHopClk(2);
20995
20996
2/4
✓ Branch 0 taken 12538 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12538 times.
12538 if(charging || spins>5)
20997 {
20998 //if Hero is charging, he might be facing the wrong direction (we want him to
20999 //hop into the water, not in the facing direction)
21000 ret.setDir(d2);
21001 //moreover Hero can't charge in the water -DD
21002 ret.setChargeAttack();
21003 }
21004
21005 12538 ret.setUnwalkable(false);
21006 12538 return ret;
21007 }
21008
2/2
✓ Branch 0 taken 561 times.
✓ Branch 1 taken 6391 times.
6952 else if(dir==d2)
21009 {
21010 6391 ret.setIlswim(true);
21011 6391 ladderx = 0;
21012 6391 laddery = 0;
21013 6391 }
21014 6952 }
21015 2566967 }
21016 2566967 }
21017
21018 // check if he can use the ladder
21019 // "Allow Ladder Anywhere" is toggled by fLADDER
21020
2/2
✓ Branch 0 taken 9371975 times.
✓ Branch 1 taken 3011760 times.
12383735 if(can_deploy_ladder())
21021 // laddersetup
21022 {
21023 // Check if there's water to use the ladder over
21024 3011760 bool wtrx = (iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy) != 0);
21025 3011760 bool wtrx8 = (iswaterex_z3(MAPCOMBO(x+8,wy), -1, x+8,wy) != 0);
21026 3011760 int32_t ldrid = current_item_id(itype_ladder);
21027
1/2
✓ Branch 0 taken 3011760 times.
✗ Branch 1 not taken.
3011760 bool ladderpits = ldrid > -1 && (itemsbuf[ldrid].flags&item_flag1);
21028
21029
4/4
✓ Branch 0 taken 3001809 times.
✓ Branch 1 taken 9951 times.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 3001744 times.
3011760 if(wtrx || wtrx8)
21030 {
21031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10016 times.
10016 if(isSideViewHero())
21032 {
21033 wtrx = !_walkflag(wx, wy+8, 1,STANDING_Z_STATE) && !_walkflag(wx, wy, 1,STANDING_Z_STATE) && dir!=down;
21034 wtrx8 = !_walkflag(wx+8, wy+8, 1,STANDING_Z_STATE) && !_walkflag(wx+8, wy, 1,STANDING_Z_STATE) && dir!=down;
21035 }
21036 // * walk on half-water using the ladder instead of using flippers.
21037 // * otherwise, walk on ladder(+hookshot) combos.
21038
3/8
✓ Branch 0 taken 633 times.
✓ Branch 1 taken 9383 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 633 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
10016 else if(wtrx==wtrx8 && (isstepable(MAPCOMBO(wx, wy)) || isstepable(MAPCOMBO(wx+8,wy)) || wtrx==true))
21039 {
21040
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 502 times.
633 if(!get_qr(qr_OLD_210_WATER))
21041 {
21042 //if Hero could swim on a tile instead of using the ladder,
21043 //refuse to use the ladder to step over that tile. -DD
21044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 502 times.
502 wtrx = isstepable(MAPCOMBO(wx, wy)) && unwalkablex;
21045
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 496 times.
502 wtrx8 = isstepable(MAPCOMBO(wx+8,wy)) && unwalkablex8;
21046 502 }
21047 633 }
21048 10016 }
21049 else
21050 {
21051 // No water; check other things
21052
21053 //Check pits
21054
2/2
✓ Branch 0 taken 3000717 times.
✓ Branch 1 taken 1027 times.
3001744 if(ladderpits)
21055 {
21056 1027 int32_t pit_cmb = getpitfall(wx,wy);
21057
1/2
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
1027 wtrx = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
21058 1027 pit_cmb = getpitfall(x+8,wy);
21059
1/2
✓ Branch 0 taken 1027 times.
✗ Branch 1 not taken.
1027 wtrx8 = pit_cmb && (combobuf[pit_cmb].usrflags&cflag4);
21060 1027 }
21061
4/6
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 3000717 times.
✓ Branch 2 taken 1027 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1027 times.
✗ Branch 5 not taken.
3001744 if(!ladderpits || (!(wtrx || wtrx8) || isSideViewHero())) //If no pit, check ladder combos
21062 {
21063 3001744 int32_t combo=combobuf[MAPCOMBO(wx, wy)].type;
21064
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 3001558 times.
3001744 wtrx=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
21065 3001744 combo=combobuf[MAPCOMBO(wx+8, wy)].type;
21066
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 3001452 times.
3001744 wtrx8=(combo==cLADDERONLY || combo==cLADDERHOOKSHOT);
21067 3001744 }
21068 }
21069
21070
2/2
✓ Branch 0 taken 6023520 times.
✓ Branch 1 taken 3011760 times.
9035280 for (int32_t i = 0; i <= 1; ++i)
21071 {
21072
2/2
✓ Branch 0 taken 5649190 times.
✓ Branch 1 taken 374330 times.
6023520 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21073 {
21074
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5649190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5649190 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && !_walkflag_layer(wx,wy,i)) wtrx = false;
21075
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5649190 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5649190 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && !_walkflag_layer(wx+8,wy,i)) wtrx8 = false;
21076 5649190 }
21077 else
21078 {
21079
3/4
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 374071 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 259 times.
374330 if (combobuf[MAPCOMBO2(i,wx,wy)].type == cBRIDGE && _effectflag_layer(wx,wy,i)) wtrx = false;
21080
3/4
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 374093 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 237 times.
374330 if (combobuf[MAPCOMBO2(i,wx+8,wy)].type == cBRIDGE && _effectflag_layer(wx+8,wy,i)) wtrx8 = false;
21081 }
21082 6023520 }
21083
2/2
✓ Branch 0 taken 2062592 times.
✓ Branch 1 taken 949168 times.
3011760 bool walkwater = (get_qr(qr_DROWN) && !iswaterex_z3(MAPCOMBO(wx,wy), -1, wx,wy));
21084
21085
4/6
✓ Branch 0 taken 2202554 times.
✓ Branch 1 taken 809206 times.
✓ Branch 2 taken 2202554 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2202554 times.
3011760 if((diagonalMovement||NO_GRIDLOCK))
21086 {
21087
2/2
✓ Branch 0 taken 160069 times.
✓ Branch 1 taken 649137 times.
809206 if(d2==dir)
21088 {
21089 649137 int32_t c = walkwater ? 0:8;
21090 649137 int32_t b = walkwater ? 8:0;
21091
21092
2/2
✓ Branch 0 taken 422599 times.
✓ Branch 1 taken 226538 times.
649137 if(d2>=left)
21093 {
21094 // If the difference between wy and y is small enough
21095
4/4
✓ Branch 0 taken 126967 times.
✓ Branch 1 taken 295632 times.
✓ Branch 2 taken 422441 times.
✓ Branch 3 taken 158 times.
422599 if(abs((wy)-(int32_t(y+c)))<=(b) && wtrx)
21096 {
21097 // Don't activate the ladder if it would be entirely
21098 // over water and Hero has the flippers. This isn't
21099 // a good way to do this, but it's too risky
21100 // to make big changes to this stuff.
21101 158 bool deployLadder=true;
21102 158 int32_t lx= TRUNCATE_TILE(wx);
21103
6/8
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 156 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 156 times.
✓ Branch 7 taken 2 times.
158 if(current_item(itype_flippers) && current_item(itype_flippers) >= combobuf[iswaterex_z3(MAPCOMBO(lx+8, y+8), -1, lx+8, y+8)].attribytes[0] && z==0 && fakez==0)
21104 {
21105
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
2 if(iswaterex_z3(MAPCOMBO(lx, y), -1, lx, y) &&
21106 iswaterex_z3(MAPCOMBO(lx+15, y), -1, lx+15, y) &&
21107 iswaterex_z3(MAPCOMBO(lx, y+15), -1, lx, y+15) &&
21108 iswaterex_z3(MAPCOMBO(lx+15, y+15), -1, lx+15, y+15))
21109 deployLadder=false;
21110 2 }
21111
1/2
✓ Branch 0 taken 158 times.
✗ Branch 1 not taken.
158 if(deployLadder)
21112 {
21113 158 ladderx = TRUNCATE_TILE(wx);
21114 158 laddery = y;
21115 158 ladderdir = left;
21116 158 ladderstart = d2;
21117 158 ret.setUnwalkable(laddery!=y.getInt());
21118 158 return ret;
21119 }
21120 }
21121 422441 }
21122
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226538 times.
226538 else if(d2<=down)
21123 {
21124 // If the difference between wx and x is small enough
21125
4/4
✓ Branch 0 taken 89635 times.
✓ Branch 1 taken 136903 times.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 226451 times.
226538 if(abs((wx)-(int32_t(x+c)))<=(b) && wtrx)
21126 {
21127 87 ladderx = x;
21128 87 laddery = TRUNCATE_TILE(wy);
21129 87 ladderdir = up;
21130 87 ladderstart = d2;
21131 87 ret.setUnwalkable(ladderx!=x.getInt());
21132 87 return ret;
21133 }
21134
21135
2/2
✓ Branch 0 taken 89594 times.
✓ Branch 1 taken 136857 times.
226451 if(cnt==2)
21136 {
21137
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 136857 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 136840 times.
136857 if(abs((wx+8)-(int32_t(x+c)))<=(b) && wtrx8)
21138 {
21139 17 ladderx = x;
21140 17 laddery = TRUNCATE_TILE(wy);
21141 17 ladderdir = up;
21142 17 ladderstart = d2;
21143 17 ret.setUnwalkable(ladderx!=x.getInt());
21144 17 return ret;
21145 }
21146 136840 }
21147 226434 }
21148 648875 }
21149 808944 }
21150 else
21151 {
21152
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2202554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2202554 times.
✓ Branch 4 taken 116610 times.
✓ Branch 5 taken 2085944 times.
2202554 bool flgx = _walkflag(wx,wy,1,STANDING_Z_STATE) && !wtrx; // Solid, and not steppable
21153
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2202554 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2202554 times.
✓ Branch 4 taken 2015835 times.
✓ Branch 5 taken 186719 times.
2202554 bool flgx8 = _walkflag(x+8,wy,1,STANDING_Z_STATE) && !wtrx8; // Solid, and not steppable
21154
21155
2/2
✓ Branch 0 taken 2039953 times.
✓ Branch 1 taken 162601 times.
2202626 if((d2>=left && wtrx)
21156 // Deploy the ladder vertically even if Hero is only half on water.
21157
8/8
✓ Branch 0 taken 18496 times.
✓ Branch 1 taken 2021457 times.
✓ Branch 2 taken 162601 times.
✓ Branch 3 taken 2021457 times.
✓ Branch 4 taken 1222 times.
✓ Branch 5 taken 161379 times.
✓ Branch 6 taken 72 times.
✓ Branch 7 taken 162529 times.
2202554 || (d2<=down && ((wtrx && !flgx8) || (wtrx8 && !flgx))))
21158 {
21159
4/4
✓ Branch 0 taken 17936 times.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 697 times.
✓ Branch 3 taken 17239 times.
18496 if(((y.getInt()+15) < wy) || ((y.getInt()+8) > wy))
21160 1257 ladderdir = up;
21161 else
21162 17239 ladderdir = left;
21163
21164
2/2
✓ Branch 0 taken 17239 times.
✓ Branch 1 taken 1257 times.
18496 if(ladderdir==up)
21165 {
21166 1257 ladderx = TRUNCATE_HALF_TILE(x.getInt());
21167 1257 laddery = TRUNCATE_TILE(wy);
21168 1257 }
21169 else
21170 {
21171 17239 ladderx = TRUNCATE_TILE(wx);
21172 17239 laddery = TRUNCATE_HALF_TILE(y.getInt());
21173
21174 }
21175
21176 18496 ret.setUnwalkable(false);
21177 18496 return ret;
21178 }
21179 }
21180 2993002 }
21181 12364977 }
21182
21183 31053658 ret.setUnwalkable(wf);
21184 31053658 return ret;
21185 32534711 }
21186
21187 // Only checks for moving blocks. Apparently this is a thing we need.
21188 3051885 HeroClass::WalkflagInfo HeroClass::walkflagMBlock(int32_t wx,int32_t wy)
21189 {
21190 3051885 HeroClass::WalkflagInfo ret;
21191
2/2
✓ Branch 0 taken 47939 times.
✓ Branch 1 taken 3003946 times.
3051885 if (!mblock2.active()) //Without this, weird swimming behaviors happen.
21192 {
21193 3003946 ret.setFlags(~1);
21194 3003946 ret.setHopDir(-1);
21195 3003946 }
21196
2/2
✓ Branch 0 taken 2808 times.
✓ Branch 1 taken 3049077 times.
3051885 if(toogam) return ret;
21197
2/2
✓ Branch 0 taken 3001138 times.
✓ Branch 1 taken 47939 times.
3049077 if (mblock2.active())
21198 47939 ret.setUnwalkable(mblock2.hit(wx,wy,0,1,1,1));
21199
2/2
✓ Branch 0 taken 3048827 times.
✓ Branch 1 taken 250 times.
3049077 if (collide_object(wx, wy,1, 1))
21200 250 ret.setUnwalkable(true);
21201 3049077 return ret;
21202 3051885 }
21203
21204 14091142 bool HeroClass::checksoliddamage()
21205 {
21206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14091142 times.
14091142 if(toogam) return false;
21207
21208
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14091142 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14091142 if (get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && get_qr(qr_NOSOLIDDAMAGECOMBOS)) return false; //no point checking if both of these rules are on
21209
21210
2/4
✓ Branch 0 taken 14091142 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14091142 times.
14091142 if(z!=0||fakez!=0) return false;
21211 14091142 int32_t bx = x.getInt();
21212 14091142 int32_t by = y.getInt();
21213 14091142 int32_t initk = 0;
21214
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3474039 times.
✓ Branch 2 taken 2822008 times.
✓ Branch 3 taken 3768622 times.
✓ Branch 4 taken 4026473 times.
14091142 switch(dir)
21215 {
21216 case up:
21217
21218
2/2
✓ Branch 0 taken 84937 times.
✓ Branch 1 taken 3389102 times.
3474039 by-=get_qr(qr_NEW_HERO_MOVEMENT2)?(bigHitbox ? 4 : -4):(bigHitbox ? 1 : -7);
21219
2/2
✓ Branch 0 taken 83482 times.
✓ Branch 1 taken 3390557 times.
3474039 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) bx += 8;
21220
2/2
✓ Branch 0 taken 3389200 times.
✓ Branch 1 taken 1357 times.
3390557 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) bx += 4;
21221
2/2
✓ Branch 0 taken 3473925 times.
✓ Branch 1 taken 114 times.
3474039 if(by<0)
21222 {
21223 114 return false;
21224 }
21225 3473925 break;
21226
21227 case down:
21228
21229 2822008 by+=20;
21230
2/2
✓ Branch 0 taken 27162 times.
✓ Branch 1 taken 2794846 times.
2822008 if (by >= world_h)
21231 {
21232 27162 return false;
21233 }
21234
21235 2794846 break;
21236
21237 case left:
21238 3768622 bx-=get_qr(qr_NEW_HERO_MOVEMENT2)?1:4;
21239
2/2
✓ Branch 0 taken 119761 times.
✓ Branch 1 taken 3648861 times.
3768622 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
21240
2/2
✓ Branch 0 taken 3647141 times.
✓ Branch 1 taken 1720 times.
3648861 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
21241
4/4
✓ Branch 0 taken 3683976 times.
✓ Branch 1 taken 84646 times.
✓ Branch 2 taken 119761 times.
✓ Branch 3 taken 3564215 times.
3768622 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
21242 {
21243 3564215 by+=8;
21244 3564215 initk = 1;
21245 3564215 }
21246
2/2
✓ Branch 0 taken 3748174 times.
✓ Branch 1 taken 20448 times.
3768622 if(bx<0)
21247 {
21248 20448 return false;
21249 }
21250
21251 3748174 break;
21252
21253 case right:
21254 4026473 bx+=get_qr(qr_NEW_HERO_MOVEMENT2)?16:20;
21255
2/2
✓ Branch 0 taken 118008 times.
✓ Branch 1 taken 3908465 times.
4026473 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) by += bigHitbox?7:11;
21256
2/2
✓ Branch 0 taken 3905137 times.
✓ Branch 1 taken 3328 times.
3908465 else if (!get_qr(qr_SENSITIVE_SOLID_DAMAGE)) by += 4;
21257
4/4
✓ Branch 0 taken 3931614 times.
✓ Branch 1 taken 94859 times.
✓ Branch 2 taken 118008 times.
✓ Branch 3 taken 3813606 times.
4026473 if (!bigHitbox && !get_qr(qr_LENIENT_SOLID_DAMAGE))
21258 {
21259 3813606 by+=8;
21260 3813606 initk = 1;
21261 3813606 }
21262
2/2
✓ Branch 0 taken 29270 times.
✓ Branch 1 taken 3997203 times.
4026473 if (bx >= world_w)
21263 {
21264 29270 return false;
21265 }
21266
21267 3997203 break;
21268 }
21269
21270 14014148 newcombo const& cmb = combobuf[MAPCOMBO(bx, by)];
21271 14014148 int32_t t = cmb.type;
21272
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 14014032 times.
14014148 if(cmb.only_gentrig)
21273 116 t = cNONE;
21274 14014148 int32_t initbx = bx;
21275 14014148 int32_t initby = by;
21276
21277 // Unlike push blocks, damage combos should be tested on layers 2 and under
21278
2/2
✓ Branch 0 taken 25578976 times.
✓ Branch 1 taken 14014133 times.
39593109 for(int32_t i=(get_qr(qr_DMGCOMBOLAYERFIX) ? 2 : 0); i>=0; i--)
21279 {
21280 25578976 bx = initbx;
21281 25578976 by = initby;
21282
2/2
✓ Branch 0 taken 7733663 times.
✓ Branch 1 taken 17845313 times.
25578976 if (!get_qr(qr_NOSOLIDDAMAGECOMBOS))
21283 {
21284
2/2
✓ Branch 0 taken 16549583 times.
✓ Branch 1 taken 42376402 times.
58925985 for (int32_t k = initk; k <= 2; k++)
21285 {
21286 42376402 auto rpos_handle = get_rpos_handle_for_world_xy(bx, by, i);
21287 42376402 auto& cmb = rpos_handle.combo();
21288 42376402 t = cmb.type;
21289
2/2
✓ Branch 0 taken 42376057 times.
✓ Branch 1 taken 345 times.
42376402 if(cmb.only_gentrig)
21290 345 t = cNONE;
21291 // Solid damage combos use pushing>0, hence the code is here.
21292
9/10
✓ Branch 0 taken 2299011 times.
✓ Branch 1 taken 40077391 times.
✓ Branch 2 taken 76893 times.
✓ Branch 3 taken 2222118 times.
✓ Branch 4 taken 74004 times.
✓ Branch 5 taken 2889 times.
✓ Branch 6 taken 1566 times.
✓ Branch 7 taken 72438 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1566 times.
42376402 if (!get_qr(qr_LESS_AWFUL_SIDESPIKES) || !isSideViewHero() || (dir != down && (dir != up || getOnSideviewLadder())))
21293 {
21294
13/16
✓ Branch 0 taken 42343594 times.
✓ Branch 1 taken 28353 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28353 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 28353 times.
✓ Branch 6 taken 1265 times.
✓ Branch 7 taken 27088 times.
✓ Branch 8 taken 169 times.
✓ Branch 9 taken 1096 times.
✓ Branch 10 taken 67 times.
✓ Branch 11 taken 102 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 67 times.
✓ Branch 14 taken 42371880 times.
✓ Branch 15 taken 67 times.
42371947 if(combo_class_buf[t].modify_hp_amount && _walkflag(bx,by,1,STANDING_Z_STATE) && pushing>0 && hclk<1 && action!=casting && action != sideswimcasting)
21295 {
21296 // Bite Hero
21297
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 8 times.
67 if (checkdamagecombos(bx, bx, by, by, i-1, true)) return true;
21298 59 }
21299 42371939 }
21300
2/2
✓ Branch 0 taken 22659971 times.
✓ Branch 1 taken 19716423 times.
42376394 if (dir < left) bx += (k % 2) ? 7 : 8;
21301 19716423 else by += (k % 2) ? 7 : 8;
21302
2/2
✓ Branch 0 taken 42309286 times.
✓ Branch 1 taken 67108 times.
42376394 if (!is_in_world_bounds(bx, by)) break;
21303
2/2
✓ Branch 0 taken 41080672 times.
✓ Branch 1 taken 1228614 times.
42309286 if (get_qr(qr_LENIENT_SOLID_DAMAGE)) break;
21304 41080672 }
21305 17845305 }
21306
4/6
✓ Branch 0 taken 479796 times.
✓ Branch 1 taken 25099172 times.
✓ Branch 2 taken 479796 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 446811 times.
26025779 if(isSideViewHero() && !get_qr(qr_NO_SIDEVIEW_SOLID_DAMAGE) && // Check for sideview damage combos
21307
3/4
✓ Branch 0 taken 446811 times.
✓ Branch 1 taken 32985 times.
✓ Branch 2 taken 446811 times.
✗ Branch 3 not taken.
479796 hclk<1 && action!=casting && action!=sideswimcasting) // ... but only if Hero could be hurt
21308 {
21309
2/2
✓ Branch 0 taken 35562 times.
✓ Branch 1 taken 411249 times.
446811 if (get_qr(qr_LESS_AWFUL_SIDESPIKES))
21310 {
21311
2/6
✓ Branch 0 taken 35562 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35562 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
35562 if (on_sideview_solid_oldpos(this) && (!getOnSideviewLadder() || getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)))
21312 {
21313
4/4
✓ Branch 0 taken 35558 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 35560 times.
✓ Branch 3 taken 2 times.
35562 if(checkdamagecombos(x+4, x+4, y+16, y+18, i-1, false, false) && checkdamagecombos(x+12, x+12, y+16, y+18, i-1, false, false))
21314 {
21315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (checkdamagecombos(x+4, x+12, y+16, y+18, i-1, false, true)) return true;
21316 }
21317 35560 }
21318
1/2
✓ Branch 0 taken 35560 times.
✗ Branch 1 not taken.
35560 if (checkdamagecombos(x+4, x+12, y+8, y+15, i-1, false, true)) return true;
21319 35560 }
21320 else
21321 {
21322 //old 2.50.2-ish code for 2.50.0 sideview quests for er_OLDSIDEVIEWSPIKES
21323
1/2
✓ Branch 0 taken 411249 times.
✗ Branch 1 not taken.
411249 if ( get_qr(qr_OLDSIDEVIEWSPIKES ) )
21324 {
21325
2/2
✓ Branch 0 taken 411244 times.
✓ Branch 1 taken 5 times.
822498 if (checkdamagecombos(x+8-(zfix)(hero_scr->csensitive),
21326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411249 times.
411249 x+8+(zc_max(hero_scr->csensitive-1,0)),
21327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 411249 times.
411249 y+17-(get_qr(qr_LTTPCOLLISION)?hero_scr->csensitive:(hero_scr->csensitive+1)/2),
21328
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 411249 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 411249 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 411249 times.
411249 y+17+zc_max((get_qr(qr_LTTPCOLLISION)?hero_scr->csensitive:(hero_scr->csensitive+1)/2)-1,0), i-1, true))
21329 5 return true;
21330 411244 }
21331 else //2.50.1 and later
21332 {
21333 if(checkdamagecombos(x+4, x+12, y+16, y+24))
21334 return true;
21335 }
21336 }
21337
21338 446804 }
21339 25578961 }
21340
21341 14014133 return false;
21342 14091142 }
21343 14283256 void HeroClass::checkpushblock()
21344 {
21345
2/2
✓ Branch 0 taken 14953 times.
✓ Branch 1 taken 14268303 times.
14283256 if(toogam) return;
21346
21347
3/4
✓ Branch 0 taken 14249195 times.
✓ Branch 1 taken 19108 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14249195 times.
14268303 if(z!=0||fakez!=0) return;
21348
21349 // Return early in some cases..
21350 14249195 bool earlyReturn=false;
21351
21352
5/6
✓ Branch 0 taken 9724059 times.
✓ Branch 1 taken 4525136 times.
✓ Branch 2 taken 9724059 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10961450 times.
✓ Branch 5 taken 3287745 times.
14249195 if(!(diagonalMovement||NO_GRIDLOCK) || dir==left)
21353
2/2
✓ Branch 0 taken 7098964 times.
✓ Branch 1 taken 3862486 times.
10961450 if(x.getInt()&15) earlyReturn=true;
21354
21355
4/4
✓ Branch 0 taken 319027 times.
✓ Branch 1 taken 13930168 times.
✓ Branch 2 taken 160974 times.
✓ Branch 3 taken 158053 times.
14249195 if(isSideViewHero() && !on_sideview_solid_oldpos(this)) return;
21356
21357 14091142 int32_t bx = TRUNCATE_TILE(x.getInt());
21358 14091142 int32_t by = TRUNCATE_TILE(y.getInt());
21359
21360
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3474039 times.
✓ Branch 2 taken 2822008 times.
✓ Branch 3 taken 3768622 times.
✓ Branch 4 taken 4026473 times.
14091142 switch(dir)
21361 {
21362 case up:
21363
2/2
✓ Branch 0 taken 118811 times.
✓ Branch 1 taken 3355228 times.
3474039 if(y<16)
21364 {
21365 118811 earlyReturn=true;
21366 118811 break;
21367 }
21368
21369
3/4
✓ Branch 0 taken 585744 times.
✓ Branch 1 taken 2769484 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 585744 times.
3355228 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21370
21371
2/2
✓ Branch 0 taken 1945083 times.
✓ Branch 1 taken 1410145 times.
3355228 if((int32_t)x&8) bx+=16;
21372
21373 3355228 break;
21374
21375 case down:
21376
2/2
✓ Branch 0 taken 232784 times.
✓ Branch 1 taken 2589224 times.
2822008 if(y>world_h-48)
21377 {
21378 232784 earlyReturn=true;
21379 232784 break;
21380 }
21381 else
21382 {
21383 2589224 by+=16;
21384
21385
2/2
✓ Branch 0 taken 1657307 times.
✓ Branch 1 taken 931917 times.
2589224 if((int32_t)x&8) bx+=16;
21386 }
21387
21388 2589224 break;
21389
21390 case left:
21391
2/2
✓ Branch 0 taken 198553 times.
✓ Branch 1 taken 3570069 times.
3768622 if(x<32)
21392 {
21393 198553 earlyReturn=true;
21394 198553 break;
21395 }
21396 else
21397 {
21398 3570069 bx-=16;
21399
21400
2/2
✓ Branch 0 taken 2163271 times.
✓ Branch 1 taken 1406798 times.
3570069 if(y.getInt()&8)
21401 {
21402 1406798 by+=16;
21403 1406798 }
21404 }
21405
21406 3570069 break;
21407
21408 case right:
21409
2/2
✓ Branch 0 taken 208438 times.
✓ Branch 1 taken 3818035 times.
4026473 if(x>world_w-48)
21410 {
21411 208438 earlyReturn=true;
21412 208438 break;
21413 }
21414 else
21415 {
21416 3818035 bx+=16;
21417
21418
2/2
✓ Branch 0 taken 2330975 times.
✓ Branch 1 taken 1487060 times.
3818035 if(y.getInt()&8)
21419 {
21420 1487060 by+=16;
21421 1487060 }
21422 }
21423
21424 3818035 break;
21425 }
21426
21427
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 14091127 times.
14091142 if (checksoliddamage()) return;
21428
21429
2/2
✓ Branch 0 taken 7397434 times.
✓ Branch 1 taken 6693693 times.
14091127 if(earlyReturn)
21430 7397434 return;
21431
21432 6693693 int itemid=current_item_id(itype_bracelet);
21433 6693693 rpos_t rpos = COMBOPOS_REGION(bx, by);
21434 6693693 size_t combopos = RPOS_TO_POS(rpos);
21435
21436
2/2
✓ Branch 0 taken 2802637 times.
✓ Branch 1 taken 3891056 times.
6693693 bool limitedpush = (itemid>=0 && itemsbuf[itemid].flags & item_flag1);
21437
2/2
✓ Branch 0 taken 3891056 times.
✓ Branch 1 taken 2802637 times.
6693693 itemdata const* glove = itemid < 0 ? NULL : &itemsbuf[itemid];
21438
2/2
✓ Branch 0 taken 1716416 times.
✓ Branch 1 taken 10138262 times.
11854678 for(int lyr = 2; lyr >= 0; --lyr) //Top-down, in case of stacked push blocks
21439 {
21440
4/4
✓ Branch 0 taken 6437383 times.
✓ Branch 1 taken 3700879 times.
✓ Branch 2 taken 1465628 times.
✓ Branch 3 taken 4971755 times.
10138262 if(get_qr(qr_HESITANTPUSHBLOCKS)&&(pushing<4)) break;
21441
4/4
✓ Branch 0 taken 3443869 times.
✓ Branch 1 taken 1722638 times.
✓ Branch 2 taken 90987 times.
✓ Branch 3 taken 3352882 times.
5166507 if(lyr && !get_qr(qr_PUSHBLOCK_LAYER_1_2))
21442 3352882 continue;
21443 1813625 auto rpos_handle = get_rpos_handle(rpos, lyr);
21444 1813625 cpos_info& cpinfo = rpos_handle.info();
21445 1813625 mapscr* m = rpos_handle.scr;
21446
2/2
✓ Branch 0 taken 91723 times.
✓ Branch 1 taken 1721902 times.
1813625 int cid = lyr == 0 ? MAPCOMBO(bx,by) : MAPCOMBOL(lyr,bx,by);
21447 1813625 newcombo const& cmb = combobuf[cid];
21448 1813625 int f = MAPFLAG2(lyr-1,bx,by);
21449 1813625 int f2 = cmb.flag;
21450 1813625 int t = cmb.type;
21451
21452
6/6
✓ Branch 0 taken 1697853 times.
✓ Branch 1 taken 115772 times.
✓ Branch 2 taken 1693320 times.
✓ Branch 3 taken 4533 times.
✓ Branch 4 taken 2464 times.
✓ Branch 5 taken 1690856 times.
3504481 bool waitblock = (t==cPUSH_WAIT || t==cPUSH_HW || t==cPUSH_HW2) ||
21453
2/2
✓ Branch 0 taken 1689940 times.
✓ Branch 1 taken 916 times.
1690856 (t == cPUSHBLOCK && (cmb.usrflags&cflag6));
21454 1813625 int heavy = 0;
21455
4/4
✓ Branch 0 taken 1808356 times.
✓ Branch 1 taken 5269 times.
✓ Branch 2 taken 15070 times.
✓ Branch 3 taken 1793286 times.
1813625 if(t==cPUSH_HW || t==cPUSH_HEAVY)
21456 20339 heavy = 1;
21457
4/4
✓ Branch 0 taken 1789389 times.
✓ Branch 1 taken 3897 times.
✓ Branch 2 taken 2464 times.
✓ Branch 3 taken 1786925 times.
1793286 else if(t==cPUSH_HEAVY2 || t==cPUSH_HW2)
21458 6361 heavy = 2;
21459
2/2
✓ Branch 0 taken 1786009 times.
✓ Branch 1 taken 916 times.
1786925 else if(t == cPUSHBLOCK)
21460 916 heavy = cmb.attribytes[0];
21461
21462
6/6
✓ Branch 0 taken 122033 times.
✓ Branch 1 taken 1691592 times.
✓ Branch 2 taken 39487 times.
✓ Branch 3 taken 82546 times.
✓ Branch 4 taken 3776 times.
✓ Branch 5 taken 35711 times.
1813625 if(waitblock && (pushing<16 || hasMainGuy(m->screen))) continue;
21463
21464
8/8
✓ Branch 0 taken 1705803 times.
✓ Branch 1 taken 21500 times.
✓ Branch 2 taken 18610 times.
✓ Branch 3 taken 2890 times.
✓ Branch 4 taken 3028 times.
✓ Branch 5 taken 15582 times.
✓ Branch 6 taken 6293 times.
✓ Branch 7 taken 1721010 times.
1764385 if(heavy && (itemid<0 || glove->power < heavy ||
21465
3/4
✓ Branch 0 taken 12682 times.
✓ Branch 1 taken 2900 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2900 times.
21875 (limitedpush && usecounts[itemid] >= zc_max(1, glove->misc3)))) continue;
21466
21467 1721010 bool doit=false;
21468 1721010 bool changecombo=false;
21469
21470 1721010 int blockdir = dir;
21471
1/2
✓ Branch 0 taken 1721010 times.
✗ Branch 1 not taken.
1721010 if(blockdir > 3) blockdir = Y_DIR(dir);
21472
6/6
✓ Branch 0 taken 916 times.
✓ Branch 1 taken 1720094 times.
✓ Branch 2 taken 779 times.
✓ Branch 3 taken 137 times.
✓ Branch 4 taken 476 times.
✓ Branch 5 taken 303 times.
1721010 if(t == cPUSHBLOCK && (get_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING) || (f!=mfPUSHED)))
21473 {
21474
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 183 times.
✓ Branch 3 taken 221 times.
✓ Branch 4 taken 135 times.
613 switch(blockdir)
21475 {
21476 case up:
21477 74 doit = cmb.usrflags & cflag1;
21478 74 break;
21479 case down:
21480 183 doit = cmb.usrflags & cflag2;
21481 183 break;
21482 case left:
21483 221 doit = cmb.usrflags & cflag3;
21484 221 break;
21485 case right:
21486 135 doit = cmb.usrflags & cflag4;
21487 135 break;
21488 }
21489 613 bool cancel_opp = (cmb.usrflags & cflag9);
21490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613 times.
613 if(cmb.usrflags & cflag5) //Separate directions
21491 {
21492 int limit = cmb.attribytes[4+blockdir];
21493 if(limit || (cmb.usrflags & cflag9)) // don't limit if limit should be infinite
21494 {
21495 int pushes = cpinfo.pushes[blockdir];
21496 if(cancel_opp)
21497 pushes -= cpinfo.pushes[oppositeDir[blockdir]];
21498 if(pushes >= limit)
21499 doit = false;
21500 }
21501 }
21502 else
21503 {
21504
1/2
✓ Branch 0 taken 613 times.
✗ Branch 1 not taken.
613 if(int limit = cmb.attribytes[4])
21505 {
21506 if(cpinfo.sumpush() >= limit)
21507 doit = false;
21508 }
21509
1/2
✓ Branch 0 taken 613 times.
✗ Branch 1 not taken.
613 else if(cmb.usrflags & cflag9)
21510 doit = false;
21511 }
21512 613 }
21513 else
21514 {
21515
2/2
✓ Branch 0 taken 1711947 times.
✓ Branch 1 taken 8450 times.
1720397 if(is_push_flag(f,dir))
21516 {
21517 8450 doit=true;
21518 8450 }
21519
21520
7/8
✓ Branch 0 taken 1719661 times.
✓ Branch 1 taken 736 times.
✓ Branch 2 taken 1719661 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✓ Branch 5 taken 1719937 times.
✓ Branch 6 taken 1719138 times.
✓ Branch 7 taken 523 times.
3439598 if((((f2==mfPUSHUD || f2==mfPUSHUDNS|| f2==mfPUSHUDINS) && dir<=down) ||
21521
3/4
✓ Branch 0 taken 1719649 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 1719649 times.
✗ Branch 3 not taken.
1719937 ((f2==mfPUSHLR || f2==mfPUSHLRNS|| f2==mfPUSHLRINS) && dir>=left) ||
21522
3/4
✓ Branch 0 taken 1719649 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 1719649 times.
✗ Branch 3 not taken.
1719937 ((f2==mfPUSHU || f2==mfPUSHUNS || f2==mfPUSHUINS) && dir==up) ||
21523
3/4
✓ Branch 0 taken 1719335 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 1719335 times.
✗ Branch 3 not taken.
1719381 ((f2==mfPUSHD || f2==mfPUSHDNS || f2==mfPUSHDINS) && dir==down) ||
21524
3/4
✓ Branch 0 taken 1719280 times.
✓ Branch 1 taken 67 times.
✓ Branch 2 taken 1719280 times.
✗ Branch 3 not taken.
1719347 ((f2==mfPUSHL || f2==mfPUSHLNS || f2==mfPUSHLINS) && dir==left) ||
21525
3/4
✓ Branch 0 taken 1719274 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 1719274 times.
✗ Branch 3 not taken.
1719347 ((f2==mfPUSHR || f2==mfPUSHRNS || f2==mfPUSHRINS) && dir==right) ||
21526
2/2
✓ Branch 0 taken 1718947 times.
✓ Branch 1 taken 254 times.
1719661 f2==mfPUSH4 || f2==mfPUSH4NS || f2==mfPUSH4INS)&&(f!=mfPUSHED))
21527 {
21528 523 changecombo=true;
21529 523 doit=true;
21530 523 }
21531 }
21532
21533
2/2
✓ Branch 0 taken 882780 times.
✓ Branch 1 taken 837494 times.
1720274 if(get_qr(qr_SOLIDBLK))
21534 {
21535
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 243882 times.
✓ Branch 2 taken 203524 times.
✓ Branch 3 taken 170337 times.
✓ Branch 4 taken 219751 times.
837494 switch(blockdir)
21536 {
21537 case up:
21538
3/4
✓ Branch 0 taken 243882 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 243874 times.
243882 if(MAPFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfBLOCKHOLE)
21539 8 break; // ignore solidity for BLOCKHOLE flagged combos
21540
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 243874 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 243874 times.
✓ Branch 4 taken 98189 times.
✓ Branch 5 taken 145685 times.
243874 if(_walkflag(bx,by-8,2,STANDING_Z_STATE))
21541 98189 doit = false;
21542
5/8
✓ Branch 0 taken 145541 times.
✓ Branch 1 taken 144 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
✓ Branch 4 taken 144 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 145685 times.
✗ Branch 7 not taken.
145685 else if(!get_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS) && _walkflag(bx,by-16,2,STANDING_Z_STATE))
21543 doit = false; // top half wasn't checked before...
21544 243874 break;
21545
21546 case down:
21547
3/4
✓ Branch 0 taken 203524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 203514 times.
203524 if(MAPFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfBLOCKHOLE)
21548 10 break; // ignore solidity for BLOCKHOLE flagged combos
21549
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 203514 times.
✓ Branch 2 taken 203514 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92112 times.
✓ Branch 5 taken 111402 times.
203514 if(_walkflag(bx,by+24,2,STANDING_Z_STATE))
21550 92112 doit = false;
21551
5/8
✓ Branch 0 taken 111387 times.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 111402 times.
✗ Branch 7 not taken.
111402 else if(!get_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS) && _walkflag(bx,by+16,2,STANDING_Z_STATE))
21552 doit = false; // top half wasn't checked before...
21553 203514 break;
21554
21555 case left:
21556
3/4
✓ Branch 0 taken 170337 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 170321 times.
170337 if(MAPFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfBLOCKHOLE)
21557 16 break; // ignore solidity for BLOCKHOLE flagged combos
21558
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 170321 times.
✓ Branch 2 taken 170321 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 93857 times.
✓ Branch 5 taken 76464 times.
170321 if(_walkflag(bx-16,by+8,2,STANDING_Z_STATE))
21559 93857 doit = false;
21560
6/8
✓ Branch 0 taken 76386 times.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 78 times.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 76458 times.
✓ Branch 7 taken 6 times.
76464 else if(!get_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS) && _walkflag(bx-16,by,2,STANDING_Z_STATE))
21561 6 doit = false; // top half wasn't checked before...
21562 170321 break;
21563
21564 case right:
21565
3/4
✓ Branch 0 taken 219751 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 219704 times.
219751 if(MAPFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfBLOCKHOLE)
21566 47 break; // ignore solidity for BLOCKHOLE flagged combos
21567
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 219704 times.
✓ Branch 2 taken 219704 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119424 times.
✓ Branch 5 taken 100280 times.
219704 if(_walkflag(bx+16,by+8,2,STANDING_Z_STATE))
21568 119424 doit = false;
21569
5/8
✓ Branch 0 taken 100235 times.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 100280 times.
✗ Branch 7 not taken.
100280 else if(!get_qr(qr_BROKEN_PUSHBLOCK_TOP_HALF_SOLIDS) && _walkflag(bx+16,by,2,STANDING_Z_STATE))
21570 doit = false; // top half wasn't checked before...
21571 219704 break;
21572 }
21573 837494 }
21574
21575
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 610093 times.
✓ Branch 2 taken 502060 times.
✓ Branch 3 taken 276977 times.
✓ Branch 4 taken 331144 times.
1720274 switch(blockdir)
21576 {
21577 case up:
21578
4/4
✓ Branch 0 taken 608853 times.
✓ Branch 1 taken 1240 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 608513 times.
610093 if((MAPFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by-8)==mfNOBLOCKS)) doit=false;
21579
21580 610093 break;
21581
21582 case down:
21583
4/4
✓ Branch 0 taken 500820 times.
✓ Branch 1 taken 1240 times.
✓ Branch 2 taken 378 times.
✓ Branch 3 taken 500442 times.
502060 if((MAPFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx,by+24)==mfNOBLOCKS)) doit=false;
21584
21585 502060 break;
21586
21587 case left:
21588
4/4
✓ Branch 0 taken 276101 times.
✓ Branch 1 taken 876 times.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 275891 times.
276977 if((MAPFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx-16,by+8)==mfNOBLOCKS)) doit=false;
21589
21590 276977 break;
21591
21592 case right:
21593
4/4
✓ Branch 0 taken 329798 times.
✓ Branch 1 taken 1346 times.
✓ Branch 2 taken 377 times.
✓ Branch 3 taken 329421 times.
331144 if((MAPFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS||MAPCOMBOFLAG2(lyr-1,bx+16,by+8)==mfNOBLOCKS)) doit=false;
21594
21595 331144 break;
21596 }
21597
21598
2/2
✓ Branch 0 taken 1715488 times.
✓ Branch 1 taken 4786 times.
1720274 if(doit)
21599 {
21600
2/2
✓ Branch 0 taken 4733 times.
✓ Branch 1 taken 53 times.
4786 if(limitedpush)
21601 53 ++usecounts[itemid];
21602
21603 // for(int32_t i=0; i<1; i++)
21604
2/2
✓ Branch 0 taken 657 times.
✓ Branch 1 taken 4129 times.
4786 if(!mblock2.active())
21605 {
21606
2/2
✓ Branch 0 taken 521 times.
✓ Branch 1 taken 3608 times.
4129 if(is_push_flag(f,dir)) // Only erase push flags, because only push flags should be copied in the block code.
21607 3608 m->sflag[combopos] = 0;
21608
21609 4129 mblock2.blockLayer = lyr;
21610
21611
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 3870 times.
4129 if(t == cPUSHBLOCK)
21612 {
21613 259 zfix blockstep = 0.5;
21614
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 205 times.
259 if(cmb.attrishorts[0] > 0)
21615 205 blockstep = zslongToFix(cmb.attrishorts[0]*100);
21616 259 mblock2.push_new(zfix(bx),zfix(by),blockdir,f,blockstep);
21617 259 mblock2.blockinfo = cpinfo;
21618 259 mblock2.blockinfo.push(blockdir, cmb.usrflags&cflag8);
21619 259 cpinfo.clearInfo();
21620
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 205 times.
259 if(cmb.attribytes[1])
21621 205 sfx(cmb.attribytes[1],(int32_t)x);
21622 259 }
21623 else
21624 {
21625 3870 mblock2.push((zfix)bx,(zfix)by,blockdir,f);
21626
21627
2/2
✓ Branch 0 taken 2808 times.
✓ Branch 1 taken 1062 times.
3870 if(get_qr(qr_MORESOUNDS))
21628 1062 sfx(WAV_ZN1PUSHBLOCK,(int32_t)x);
21629 }
21630 4129 }
21631 4786 break;
21632 }
21633 1715488 }
21634 14282520 }
21635
21636 848 bool usekey()
21637 {
21638 848 int32_t itemid = current_item_id(itype_magickey);
21639
21640
3/4
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 60 times.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
848 if(itemid<0 ||
21641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 (itemsbuf[itemid].flags & item_flag1 ? itemsbuf[itemid].power<dlevel
21642 : itemsbuf[itemid].power!=dlevel))
21643 {
21644
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 668 times.
788 if(game->lvlkeys[dlevel]!=0)
21645 {
21646 120 game->lvlkeys[dlevel]--;
21647 //run script for level key item
21648 120 int32_t key_item = 0; //current_item_id(itype_lkey); //not possible
21649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9150 times.
9150 for ( int32_t q = 0; q < MAXITEMS; ++q )
21650 {
21651
2/2
✓ Branch 0 taken 9030 times.
✓ Branch 1 taken 120 times.
9150 if ( itemsbuf[q].type == itype_lkey )
21652 {
21653 120 key_item = q; break;
21654 }
21655 9030 }
21656
21657
2/8
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
120 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21658 {
21659 int i = key_item;
21660 FFCore.reset_script_engine_data(ScriptType::Item, i);
21661 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21662 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21663 }
21664 120 return true;
21665 }
21666 else
21667 {
21668
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 332 times.
668 if(game->get_keys()==0)
21669 {
21670 332 return false;
21671 }
21672 else
21673 {
21674 //run script for key item
21675 336 int32_t key_item = 0; //current_item_id(itype_key); //not possible
21676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3360 times.
3360 for ( int32_t q = 0; q < MAXITEMS; ++q )
21677 {
21678
2/2
✓ Branch 0 taken 3024 times.
✓ Branch 1 taken 336 times.
3360 if ( itemsbuf[q].type == itype_key )
21679 {
21680 336 key_item = q; break;
21681 }
21682 3024 }
21683
2/8
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
336 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
21684 {
21685 int i = key_item;
21686 FFCore.reset_script_engine_data(ScriptType::Item, i);
21687 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
21688 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
21689 }
21690 336 game->change_keys(-1);
21691 }
21692 }
21693 336 }
21694
21695 396 return true;
21696 848 }
21697
21698 11 bool canUseKey(int32_t num)
21699 {
21700 11 int32_t itemid = current_item_id(itype_magickey);
21701
21702
1/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11 if(itemid<0 ||
21703 (itemsbuf[itemid].flags & item_flag1 ? itemsbuf[itemid].power<dlevel
21704 : itemsbuf[itemid].power!=dlevel))
21705 {
21706 11 return game->lvlkeys[dlevel] + game->get_keys() >= num;
21707 }
21708
21709 return true;
21710 11 }
21711
21712 11 bool usekey(int32_t num)
21713 {
21714
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 8 times.
11 if(!canUseKey(num)) return false;
21715
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 8 times.
16 for(auto q = 0; q < num; ++q)
21716 {
21717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!usekey()) return false; //should never return false here, but, just to be safe....
21718 8 }
21719 8 return true;
21720 11 }
21721
21722
21723 1262 bool islockeddoor(int32_t x, int32_t y, int32_t lock)
21724 {
21725 1262 int32_t mc = (y&0xF0)+(x>>4);
21726
4/6
✓ Branch 0 taken 1262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1176 times.
✓ Branch 5 taken 86 times.
2524 bool ret = (((mc==7||mc==8||mc==23||mc==24) && origin_scr->door[up]==lock)
21727
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1262 times.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1262 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1262 times.
✗ Branch 7 not taken.
1262 || ((mc==151||mc==152||mc==167||mc==168) && origin_scr->door[down]==lock)
21728
3/6
✓ Branch 0 taken 1262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1262 times.
✗ Branch 5 not taken.
1262 || ((mc==64||mc==65||mc==80||mc==81) && origin_scr->door[left]==lock)
21729
5/8
✓ Branch 0 taken 1253 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 1253 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1253 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1253 times.
1262 || ((mc==78||mc==79||mc==94||mc==95) && origin_scr->door[right]==lock));
21730 1262 return ret;
21731 }
21732
21733 13715869 void HeroClass::oldchecklockblock()
21734 {
21735
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 13701514 times.
13715869 if(toogam) return;
21736
21737 13701514 int32_t bx = TRUNCATE_TILE(x.getInt());
21738 13701514 int32_t bx2 = TRUNCATE_TILE(x.getInt() + 8);
21739 13701514 int32_t by = TRUNCATE_TILE(y.getInt());
21740
21741
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3380863 times.
✓ Branch 2 taken 2711494 times.
✓ Branch 3 taken 3671104 times.
✓ Branch 4 taken 3938053 times.
13701514 switch(dir)
21742 {
21743 case up:
21744
4/4
✓ Branch 0 taken 588263 times.
✓ Branch 1 taken 2792600 times.
✓ Branch 2 taken 11867 times.
✓ Branch 3 taken 576396 times.
3380863 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21745
21746 3380863 break;
21747
21748 case down:
21749 2711494 by+=16;
21750 2711494 break;
21751
21752 case left:
21753
2/2
✓ Branch 0 taken 1622499 times.
✓ Branch 1 taken 2048605 times.
3671104 if((((int32_t)x)&0x0F)<8)
21754 2048605 bx-=16;
21755
21756
2/2
✓ Branch 0 taken 2252988 times.
✓ Branch 1 taken 1418116 times.
3671104 if(y.getInt()&8)
21757 {
21758 1418116 by+=16;
21759 1418116 }
21760
21761 3671104 bx2=bx;
21762 3671104 break;
21763
21764 case right:
21765 3938053 bx+=16;
21766
21767
2/2
✓ Branch 0 taken 2426950 times.
✓ Branch 1 taken 1511103 times.
3938053 if(y.getInt()&8)
21768 {
21769 1511103 by+=16;
21770 1511103 }
21771
21772 3938053 bx2=bx;
21773 3938053 break;
21774 }
21775
21776 13701514 bool found1=false;
21777 13701514 bool found2=false;
21778 13701514 int32_t foundlayer = -1;
21779 13701514 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
21780 13701514 newcombo const& cmb = combobuf[cid1];
21781 13701514 newcombo const& cmb2 = combobuf[cid2];
21782
4/6
✓ Branch 0 taken 2512 times.
✓ Branch 1 taken 13699002 times.
✓ Branch 2 taken 2512 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2512 times.
13701514 if((cmb.type==cLOCKBLOCK && !(cmb.only_gentrig) && _effectflag(bx,by,1, -1)))
21783 {
21784 // Context: https://discord.com/channels/876899628556091432/1278165595321405554
21785 // Layer 0 is overridden by Locked Doors (but only for dungeons) - in that case, checklocked will clear these combos
21786
2/2
✓ Branch 0 taken 919 times.
✓ Branch 1 taken 1593 times.
2512 bool ignore_layer_0 = isdungeon() && islockeddoor(bx,by,dLOCKED);
21787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2512 times.
2512 if (!ignore_layer_0)
21788 {
21789 2512 found1=true;
21790 2512 foundlayer = 0;
21791 2512 }
21792 2512 }
21793
4/6
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 13698797 times.
✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 205 times.
13699002 else if (cmb2.type==cLOCKBLOCK && !(cmb2.only_gentrig) && _effectflag(bx2,by,1, -1))
21794 {
21795
1/2
✓ Branch 0 taken 205 times.
✗ Branch 1 not taken.
205 bool ignore_layer_0 = isdungeon() && islockeddoor(bx2,by,dLOCKED);
21796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
205 if (!ignore_layer_0)
21797 {
21798 205 found2=true;
21799 205 foundlayer = 0;
21800 205 }
21801 205 }
21802
21803
2/2
✓ Branch 0 taken 27403028 times.
✓ Branch 1 taken 13701514 times.
41104542 for (int32_t i = 0; i <= 1; ++i)
21804 {
21805
2/2
✓ Branch 0 taken 26781664 times.
✓ Branch 1 taken 621364 times.
27403028 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21806 {
21807
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26781664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26781664 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,i)) found1 = false;
21808
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26781664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26781664 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,i)) found2 = false;
21809 26781664 }
21810 else
21811 {
21812
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 619999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
621364 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,i)) found1 = false;
21813
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 619999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
621364 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,i)) found2 = false;
21814 }
21815 27403028 }
21816
21817
21818 // Layers
21819
4/4
✓ Branch 0 taken 13699002 times.
✓ Branch 1 taken 2512 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 13698797 times.
13701514 if(!(found1 || found2))
21820 {
21821 13698797 foundlayer = -1;
21822
2/2
✓ Branch 0 taken 13698711 times.
✓ Branch 1 taken 27397559 times.
41096270 for(int32_t i=0; i<2; i++)
21823 {
21824 27397559 cid1 = MAPCOMBO2(i, bx, by);
21825 27397559 cid2 = MAPCOMBO2(i, bx2, by);
21826 27397559 newcombo const& cmb = combobuf[cid1];
21827 27397559 newcombo const& cmb2 = combobuf[cid2];
21828
2/2
✓ Branch 0 taken 13698762 times.
✓ Branch 1 taken 13698797 times.
27397559 if (i == 0)
21829 {
21830
2/2
✓ Branch 0 taken 13388194 times.
✓ Branch 1 taken 310603 times.
13698797 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21831 {
21832
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13388194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13388194 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx,by,1)) continue; //Continue, because It didn't find any on layer 0, and if you're checking
21833
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13388194 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13388194 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2,by,1)) continue; //layer 1 and there's a bridge on layer 2, stop checking layer 1.
21834 13388194 }
21835 else
21836 {
21837
4/4
✓ Branch 0 taken 1333 times.
✓ Branch 1 taken 309270 times.
✓ Branch 2 taken 881 times.
✓ Branch 3 taken 452 times.
310603 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx,by,1)) continue;
21838
3/4
✓ Branch 0 taken 881 times.
✓ Branch 1 taken 309270 times.
✓ Branch 2 taken 881 times.
✗ Branch 3 not taken.
310151 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2,by,1)) continue;
21839 }
21840 13698345 }
21841
4/6
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 27397024 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 83 times.
27397107 if(cmb.type==cLOCKBLOCK && !(cmb.only_gentrig) && _effectflag(bx,by,1, i))
21842 {
21843 83 found1=true;
21844 83 foundlayer = i+1;
21845 83 break;
21846 }
21847
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 27397021 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
27397024 else if(cmb2.type==cLOCKBLOCK && !(cmb2.only_gentrig) && _effectflag(bx2,by,1, i))
21848 {
21849 3 found2=true;
21850 3 foundlayer = i+1;
21851 3 break;
21852 }
21853 27397021 }
21854 13698797 }
21855
21856
4/4
✓ Branch 0 taken 13698919 times.
✓ Branch 1 taken 2595 times.
✓ Branch 2 taken 13701113 times.
✓ Branch 3 taken 401 times.
13701514 if(!(found1 || found2) || pushing<8)
21857 {
21858 13701113 return;
21859 }
21860
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 51 times.
401 newcombo const& cmb3 = combobuf[found1 ? cid1 : cid2];
21861
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 262 times.
401 if(!try_locked_combo(cmb3))
21862 262 return;
21863
21864
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 12 times.
139 auto rpos_handle = found1 ? get_rpos_handle_for_world_xy(bx, by, 0) : get_rpos_handle_for_world_xy(bx2, by, 0);
21865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if(cmb.usrflags&cflag16)
21866 {
21867 setxmapflag(rpos_handle.screen, 1<<cmb.attribytes[5]);
21868 remove_xstatecombos(create_screen_handles(rpos_handle.base_scr()), 1<<cmb.attribytes[5], false);
21869 }
21870 else
21871 {
21872 139 setmapflag(rpos_handle.scr, mLOCKBLOCK);
21873 139 remove_lockblocks(create_screen_handles(rpos_handle.base_scr()));
21874 }
21875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( cmb3.usrflags&cflag3 )
21876 {
21877 if ( (cmb3.attribytes[3]) )
21878 sfx(cmb3.attribytes[3]);
21879 }
21880 139 else sfx(WAV_DOOR);
21881 13715869 }
21882
21883 13715869 void HeroClass::oldcheckbosslockblock()
21884 {
21885
2/2
✓ Branch 0 taken 14355 times.
✓ Branch 1 taken 13701514 times.
13715869 if(toogam) return;
21886
21887 13701514 int32_t bx = TRUNCATE_TILE(x.getInt());
21888 13701514 int32_t bx2 = TRUNCATE_TILE(x.getInt()+8);
21889 13701514 int32_t by = TRUNCATE_TILE(y.getInt());
21890
21891
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3380863 times.
✓ Branch 2 taken 2711494 times.
✓ Branch 3 taken 3671104 times.
✓ Branch 4 taken 3938053 times.
13701514 switch(dir)
21892 {
21893 case up:
21894
4/4
✓ Branch 0 taken 588263 times.
✓ Branch 1 taken 2792600 times.
✓ Branch 2 taken 576396 times.
✓ Branch 3 taken 11867 times.
3380863 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
21895
21896 3380863 break;
21897
21898 case down:
21899 2711494 by+=16;
21900 2711494 break;
21901
21902 case left:
21903
2/2
✓ Branch 0 taken 1622499 times.
✓ Branch 1 taken 2048605 times.
3671104 if((((int32_t)x)&0x0F)<8)
21904 2048605 bx-=16;
21905
21906
2/2
✓ Branch 0 taken 2252988 times.
✓ Branch 1 taken 1418116 times.
3671104 if(y.getInt()&8)
21907 {
21908 1418116 by+=16;
21909 1418116 }
21910
21911 3671104 bx2=bx;
21912 3671104 break;
21913
21914 case right:
21915 3938053 bx+=16;
21916
21917
2/2
✓ Branch 0 taken 2426950 times.
✓ Branch 1 taken 1511103 times.
3938053 if(y.getInt()&8)
21918 {
21919 1511103 by+=16;
21920 1511103 }
21921
21922 3938053 bx2=bx;
21923 3938053 break;
21924 }
21925
21926
21927 13701514 bool found1 = false;
21928 13701514 bool found2 = false;
21929 13701514 int32_t foundlayer = -1;
21930 13701514 int32_t cid1 = MAPCOMBO(bx, by), cid2 = MAPCOMBO(bx2, by);
21931 13701514 newcombo const& cmb = combobuf[cid1];
21932 13701514 newcombo const& cmb2 = combobuf[cid2];
21933 13701514 int cmb_screen_index = 0;
21934
21935
4/6
✓ Branch 0 taken 1327 times.
✓ Branch 1 taken 13700187 times.
✓ Branch 2 taken 1327 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1327 times.
13701514 if((cmb.type==cBOSSLOCKBLOCK && !(cmb.only_gentrig) && _effectflag(bx,by,1, -1)))
21936 {
21937 // Context: https://discord.com/channels/876899628556091432/1278165595321405554
21938 // Layer 0 is overridden by Locked Doors (but only for dungeons) - in that case, checklocked will clear these combos
21939
2/2
✓ Branch 0 taken 1006 times.
✓ Branch 1 taken 321 times.
1327 bool ignore_layer_0 = isdungeon() && islockeddoor(bx,by,dBOSS);
21940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1327 times.
1327 if (!ignore_layer_0)
21941 {
21942 1327 found1=true;
21943 1327 foundlayer = 0;
21944 1327 cmb_screen_index = get_screen_for_world_xy(bx, by);
21945 1327 }
21946 1327 }
21947
4/6
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 13700156 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 31 times.
13700187 else if (cmb2.type==cBOSSLOCKBLOCK && !(cmb2.only_gentrig) && _effectflag(bx2,by,1, -1))
21948 {
21949
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 22 times.
31 bool ignore_layer_0 = isdungeon() && islockeddoor(bx2,by,dBOSS);
21950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if (!ignore_layer_0)
21951 {
21952 31 found2=true;
21953 31 foundlayer = 0;
21954 31 cmb_screen_index = get_screen_for_world_xy(bx2, by);
21955 31 }
21956 31 }
21957
21958
2/2
✓ Branch 0 taken 27403028 times.
✓ Branch 1 taken 13701514 times.
41104542 for (int32_t i = 0; i <= 1; ++i)
21959 {
21960
2/2
✓ Branch 0 taken 26781664 times.
✓ Branch 1 taken 621364 times.
27403028 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21961 {
21962
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26781664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26781664 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && !_walkflag_layer(bx, by, i)) found1 = false;
21963
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26781664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26781664 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && !_walkflag_layer(bx2, by, i)) found2 = false;
21964 26781664 }
21965 else
21966 {
21967
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 619999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
621364 if (combobuf[MAPCOMBO2(i, bx, by)].type == cBRIDGE && _effectflag_layer(bx, by, i)) found1 = false;
21968
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 619999 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
621364 if (combobuf[MAPCOMBO2(i, bx2, by)].type == cBRIDGE && _effectflag_layer(bx2, by, i)) found2 = false;
21969 }
21970 27403028 }
21971
21972
21973 // Layers
21974
4/4
✓ Branch 0 taken 13700187 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 13700156 times.
13701514 if (!(found1 || found2))
21975 {
21976 13700156 foundlayer = -1;
21977
2/2
✓ Branch 0 taken 13700156 times.
✓ Branch 1 taken 27400312 times.
41100468 for (int32_t i = 0; i < 2; i++)
21978 {
21979 27400312 cid1 = MAPCOMBO2(i, bx, by);
21980 27400312 cid2 = MAPCOMBO2(i, bx2, by);
21981 27400312 newcombo const& cmb = combobuf[cid1];
21982 27400312 newcombo const& cmb2 = combobuf[cid2];
21983
2/2
✓ Branch 0 taken 13700156 times.
✓ Branch 1 taken 13700156 times.
27400312 if (i == 0)
21984 {
21985
2/2
✓ Branch 0 taken 11798354 times.
✓ Branch 1 taken 1901802 times.
13700156 if (get_scr_layer_valid(current_screen, 2))
21986 {
21987
2/2
✓ Branch 0 taken 1767354 times.
✓ Branch 1 taken 134448 times.
1901802 if (get_qr(qr_OLD_BRIDGE_COMBOS))
21988 {
21989
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1767354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1767354 if (combobuf[cid1].type == cBRIDGE && !_walkflag_layer(bx, by)) continue;
21990
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1767354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1767354 if (combobuf[cid2].type == cBRIDGE && !_walkflag_layer(bx2, by)) continue;
21991 1767354 }
21992 else
21993 {
21994
3/4
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 133996 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 452 times.
134448 if (combobuf[cid1].type == cBRIDGE && _effectflag_layer(bx, by)) continue;
21995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133996 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133996 if (combobuf[cid2].type == cBRIDGE && _effectflag_layer(bx2, by)) continue;
21996 }
21997 1901350 }
21998 13699704 }
21999
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27399860 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27399860 if (cmb.type == cBOSSLOCKBLOCK && !(cmb.only_gentrig) && _effectflag(bx, by, 1, i))
22000 {
22001 found1 = true;
22002 foundlayer = i;
22003 cmb_screen_index = get_screen_for_world_xy(bx, by);
22004 break;
22005 }
22006
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27399860 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27399860 else if (cmb2.type == cBOSSLOCKBLOCK && !(cmb2.only_gentrig) && _effectflag(bx2, by, 1, i))
22007 {
22008 found2 = true;
22009 foundlayer = i;
22010 cmb_screen_index = get_screen_for_world_xy(bx2, by);
22011 break;
22012 }
22013 27399860 }
22014 13700156 }
22015
22016
4/4
✓ Branch 0 taken 13700187 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 13701043 times.
✓ Branch 3 taken 471 times.
13701514 if (!(found1 || found2) || pushing < 8)
22017 {
22018 13701043 return;
22019 }
22020
2/2
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 3 times.
471 int32_t cid = found1 ? cid1 : cid2;
22021
22022
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 436 times.
471 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
22023
22024
22025 // Run Boss Key Script
22026 35 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
22027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2380 times.
2380 for ( int32_t q = 0; q < MAXITEMS; ++q )
22028 {
22029
2/2
✓ Branch 0 taken 2345 times.
✓ Branch 1 taken 35 times.
2380 if ( itemsbuf[q].type == itype_bosskey )
22030 {
22031 35 key_item = q; break;
22032 }
22033 2345 }
22034
2/8
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
35 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
22035 {
22036 int i = key_item;
22037 FFCore.reset_script_engine_data(ScriptType::Item, i);
22038 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
22039 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
22040 }
22041
22042 35 mapscr* scr = get_scr(cmb_screen_index);
22043
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(cmb.usrflags&cflag16)
22044 {
22045 setxmapflag(cmb_screen_index, 1<<cmb.attribytes[5]);
22046 remove_xstatecombos(create_screen_handles(scr), 1<<cmb.attribytes[5]);
22047 }
22048 else
22049 {
22050 35 setmapflag(scr, mBOSSLOCKBLOCK);
22051 35 remove_bosslockblocks(create_screen_handles(scr));
22052 }
22053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( (combobuf[cid].attribytes[3]) )
22054 35 sfx(combobuf[cid].attribytes[3]);
22055 13715869 }
22056
22057 39689814 void HeroClass::oldcheckchest(int32_t type)
22058 {
22059 // chests aren't affected by hero_scr->flags2&fAIRCOMBOS
22060
5/6
✓ Branch 0 taken 39649596 times.
✓ Branch 1 taken 40218 times.
✓ Branch 2 taken 39608847 times.
✓ Branch 3 taken 40749 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 39608847 times.
39689814 if(toogam || z>0 || fakez > 0) return;
22061
2/2
✓ Branch 0 taken 37981761 times.
✓ Branch 1 taken 1627086 times.
39608847 if(pushing<8) return;
22062
22063 1627086 int32_t bx = TRUNCATE_TILE(x.getInt());
22064 1627086 int32_t bx2 = TRUNCATE_TILE(x.getInt()+8);
22065 1627086 int32_t by = TRUNCATE_TILE(y.getInt());
22066
22067
3/4
✓ Branch 0 taken 872424 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 347538 times.
✓ Branch 3 taken 407124 times.
1627086 switch(dir)
22068 {
22069 case up:
22070
2/2
✓ Branch 0 taken 52566 times.
✓ Branch 1 taken 354558 times.
407124 if(isSideViewHero()) return;
22071
22072
4/4
✓ Branch 0 taken 81006 times.
✓ Branch 1 taken 273552 times.
✓ Branch 2 taken 78609 times.
✓ Branch 3 taken 2397 times.
354558 if(!((int32_t)y&15)&&y!=0) by-=bigHitbox ? 16 : 0;
22073
22074 354558 break;
22075
22076 case left:
22077 case right:
22078
2/2
✓ Branch 0 taken 19974 times.
✓ Branch 1 taken 852450 times.
872424 if(isSideViewHero()) break;
22079 [[fallthrough]];
22080 case down:
22081 1199988 return;
22082 }
22083
22084 374532 bool found=false;
22085 374532 int found_screen_index=0;
22086 374532 bool itemflag=false;
22087
22088
3/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 374395 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 137 times.
374532 if (combobuf[MAPCOMBO(bx,by)].type==type && _effectflag(bx,by,1, -1))
22089 {
22090 137 found=true;
22091 137 found_screen_index=get_screen_for_world_xy(bx, by);
22092 137 }
22093
3/4
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 374360 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 35 times.
374395 else if (combobuf[MAPCOMBO(bx2,by)].type==type && _effectflag(bx2,by,1, -1))
22094 {
22095 35 found=true;
22096 35 found_screen_index=get_screen_for_world_xy(bx2, by);
22097 35 }
22098
2/2
✓ Branch 0 taken 749064 times.
✓ Branch 1 taken 374532 times.
1123596 for (int32_t i = 0; i <= 1; ++i)
22099 {
22100
2/2
✓ Branch 0 taken 747864 times.
✓ Branch 1 taken 1200 times.
749064 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22101 {
22102
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 747864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
747864 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,i)) found = false;
22103
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 747864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
747864 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,i)) found = false;
22104 747864 }
22105 else
22106 {
22107
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1200 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,i)) found = false;
22108
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1200 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1200 if (combobuf[MAPCOMBO2(i,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,i)) found = false;
22109 }
22110 749064 }
22111
22112
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 374360 times.
374532 if(!found)
22113 {
22114
2/2
✓ Branch 0 taken 374360 times.
✓ Branch 1 taken 748720 times.
1123080 for(int32_t i=0; i<2; i++)
22115 {
22116
2/2
✓ Branch 0 taken 374360 times.
✓ Branch 1 taken 374360 times.
748720 if (i == 0)
22117 {
22118
2/2
✓ Branch 0 taken 373760 times.
✓ Branch 1 taken 600 times.
374360 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22119 {
22120
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 373760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
373760 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1)) continue;
22121
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 373760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
373760 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && !_walkflag_layer(bx2,by,1)) continue;
22122 373760 }
22123 else
22124 {
22125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
600 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1)) continue;
22126
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 600 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
600 if (combobuf[MAPCOMBO2(1,bx2,by)].type == cBRIDGE && _effectflag_layer(bx2,by,1)) continue;
22127 }
22128 374360 }
22129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 748720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
748720 if (combobuf[MAPCOMBO2(i,bx,by)].type==type && _effectflag(bx,by,1, i))
22130 {
22131 found=true;
22132 found_screen_index=get_screen_for_world_xy(bx, by);
22133 break;
22134 }
22135
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 748720 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
748720 else if (combobuf[MAPCOMBO2(i,bx2,by)].type==type && _effectflag(bx2,by,1, i))
22136 {
22137 found=true;
22138 found_screen_index=get_screen_for_world_xy(bx2, by);
22139 break;
22140 }
22141 748720 }
22142 374360 }
22143
22144
2/2
✓ Branch 0 taken 172 times.
✓ Branch 1 taken 374360 times.
374532 if(!found)
22145 {
22146 374360 return;
22147 }
22148
22149 172 mapscr* scr = get_scr(found_screen_index);
22150
22151
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
✓ Branch 2 taken 101 times.
✓ Branch 3 taken 2 times.
172 switch(type)
22152 {
22153 case cLOCKEDCHEST:
22154
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 56 times.
69 if(!usekey()) return;
22155
22156 13 setmapflag(scr, mLOCKEDCHEST);
22157 13 break;
22158
22159 case cCHEST:
22160 101 setmapflag(scr, mCHEST);
22161 101 break;
22162
22163 case cBOSSCHEST:
22164
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!(game->lvlitems[dlevel]&liBOSSKEY)) return;
22165 // Run Boss Key Script
22166 2 int32_t key_item = 0; //current_item_id(itype_bosskey); //not possible
22167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 for ( int32_t q = 0; q < MAXITEMS; ++q )
22168 {
22169
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 2 times.
136 if ( itemsbuf[q].type == itype_bosskey )
22170 {
22171 2 key_item = q; break;
22172 }
22173 134 }
22174
2/8
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2 if ( key_item > 0 && itemsbuf[key_item].script && !(FFCore.doscript(ScriptType::Item, key_item) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)) )
22175 {
22176 int i = key_item;
22177 FFCore.reset_script_engine_data(ScriptType::Item, i);
22178 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[i].script, i);
22179 FFCore.deallocateAllScriptOwned(ScriptType::Item,(key_item));
22180 }
22181 2 setmapflag(scr, mBOSSCHEST);
22182 2 break;
22183 }
22184
22185 116 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
22186 116 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
22187 116 itemflag |= MAPFLAG(bx,by)==mfARMOS_ITEM;
22188 116 itemflag |= MAPFLAG(bx2,by)==mfARMOS_ITEM;
22189 116 itemflag |= MAPCOMBOFLAG(bx,by)==mfARMOS_ITEM;
22190 116 itemflag |= MAPCOMBOFLAG(bx2,by)==mfARMOS_ITEM;
22191
22192
1/2
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
116 if(!itemflag)
22193 {
22194 for(int32_t i=0; i<2; i++)
22195 {
22196 itemflag |= MAPFLAG2(i,bx,by)==mfARMOS_ITEM;
22197 itemflag |= MAPFLAG2(i,bx2,by)==mfARMOS_ITEM;
22198 itemflag |= MAPCOMBOFLAG2(i,bx,by)==mfARMOS_ITEM;
22199 itemflag |= MAPCOMBOFLAG2(i,bx2,by)==mfARMOS_ITEM;
22200 }
22201 }
22202
22203
3/6
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 116 times.
116 if(itemflag && !getmapflag(found_screen_index, (found_screen_index < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM))
22204 {
22205
4/8
✓ Branch 0 taken 116 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 116 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 116 times.
✗ Branch 7 not taken.
116 add_item_for_screen(found_screen_index, new item(x, y,(zfix)0, scr->catchall, ipONETIME2 + ipBIGRANGE + ipHOLDUP | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0), 0));
22206 116 }
22207 39689814 }
22208
22209 4294074 void HeroClass::checkchest(int32_t type)
22210 {
22211
4/4
✓ Branch 0 taken 3240894 times.
✓ Branch 1 taken 1053180 times.
✓ Branch 2 taken 1053180 times.
✓ Branch 3 taken 2187714 times.
4294074 bool ischest = type == cCHEST || type == cLOCKEDCHEST || type == cBOSSCHEST;
22212
2/2
✓ Branch 0 taken 567267 times.
✓ Branch 1 taken 3726807 times.
4294074 bool islockblock = type == cLOCKBLOCK || type == cBOSSLOCKBLOCK;
22213
2/2
✓ Branch 0 taken 567267 times.
✓ Branch 1 taken 3726807 times.
4294074 bool islocked = type == cLOCKBLOCK || type == cLOCKEDCHEST;
22214
2/2
✓ Branch 0 taken 567267 times.
✓ Branch 1 taken 3726807 times.
4294074 bool isbosslocked = type == cBOSSLOCKBLOCK || type == cBOSSCHEST;
22215
2/2
✓ Branch 0 taken 1134534 times.
✓ Branch 1 taken 3159540 times.
4294074 if(ischest)
22216 {
22217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3159540 times.
3159540 if(get_qr(qr_OLD_CHEST_COLLISION))
22218 {
22219 oldcheckchest(type);
22220 return;
22221 }
22222 3159540 }
22223
3/4
✓ Branch 0 taken 1134534 times.
✓ Branch 1 taken 3159540 times.
✓ Branch 2 taken 1134534 times.
✗ Branch 3 not taken.
4294074 if(islockblock && get_qr(qr_OLD_LOCKBLOCK_COLLISION))
22224 {
22225 if(type == cLOCKBLOCK)
22226 oldchecklockblock();
22227 else if(type == cBOSSLOCKBLOCK)
22228 oldcheckbosslockblock();
22229 return;
22230 }
22231
5/6
✓ Branch 0 taken 4288237 times.
✓ Branch 1 taken 5837 times.
✓ Branch 2 taken 4264321 times.
✓ Branch 3 taken 23916 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4264321 times.
4294074 if(toogam || z>0 || fakez > 0) return;
22232 4264321 zfix bx, by;
22233 4264321 zfix bx2, by2;
22234 4264321 zfix fx(-1), fy(-1);
22235
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 921679 times.
✓ Branch 2 taken 953170 times.
✓ Branch 3 taken 1168231 times.
✓ Branch 4 taken 1221241 times.
4264321 switch(dir)
22236 {
22237 case up:
22238 921679 by = y + (bigHitbox ? -2 : 6);
22239 921679 by2 = by;
22240 921679 bx = x + 4;
22241 921679 bx2 = bx + 8;
22242 921679 break;
22243 case down:
22244 953170 by = y + 17;
22245 953170 by2 = by;
22246 953170 bx = x + 4;
22247 953170 bx2 = bx + 8;
22248 953170 break;
22249 case left:
22250 1168231 by = y + (bigHitbox ? 0 : 8);
22251 1168231 by2 = y + 8;
22252 1168231 bx = x - 2;
22253 1168231 bx2 = x - 2;
22254 1168231 break;
22255 case right:
22256 1221241 by = y + (bigHitbox ? 0 : 8);
22257 1221241 by2 = y + 8;
22258 1221241 bx = x + 17;
22259 1221241 bx2 = x + 17;
22260 1221241 break;
22261 }
22262
22263 4264321 int32_t found = -1;
22264 4264321 int32_t foundlayer = 0;
22265
22266 4264321 newcombo const* cmb = &combobuf[MAPCOMBO(bx,by)];
22267
22268
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 4261601 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
4264321 if(cmb->type==type && !(cmb->only_gentrig) && _effectflag(bx,by,1, -1))
22269 {
22270 2720 found = MAPCOMBO(bx,by);
22271 2720 fx = bx; fy = by;
22272
2/2
✓ Branch 0 taken 5440 times.
✓ Branch 1 taken 2720 times.
8160 for (int32_t i = 0; i <= 1; ++i)
22273 {
22274
2/2
✓ Branch 0 taken 3484 times.
✓ Branch 1 taken 1956 times.
5440 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22275 {
22276
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3484 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3484 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1)) found = -1;
22277 3484 }
22278 else
22279 {
22280
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1956 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1)) found = -1;
22281 }
22282 5440 }
22283 2720 }
22284
2/2
✓ Branch 0 taken 4261601 times.
✓ Branch 1 taken 2720 times.
4264321 if(found<0)
22285 {
22286 4261601 cmb = &combobuf[MAPCOMBO(bx2,by2)];
22287
4/6
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 4261517 times.
✓ Branch 2 taken 84 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 84 times.
4261601 if(cmb->type==type && !(cmb->only_gentrig) && _effectflag(bx2,by2,1, -1))
22288 {
22289 84 found = MAPCOMBO(bx2,by2);
22290
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 504 times.
588 for (int32_t i = 0; i < 6; ++i)
22291 {
22292
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 228 times.
504 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22293 {
22294
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
276 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,i))
22295 {
22296 found = -1;
22297 break;
22298 }
22299 276 }
22300 else
22301 {
22302
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 228 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
228 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,i))
22303 {
22304 found = -1;
22305 break;
22306 }
22307 }
22308 504 }
22309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(found != -1)
22310 {
22311 84 fx = bx2; fy = by2;
22312 84 }
22313 84 }
22314 4261601 }
22315
22316
2/2
✓ Branch 0 taken 4261517 times.
✓ Branch 1 taken 2804 times.
4264321 if(found<0)
22317 {
22318
2/2
✓ Branch 0 taken 4261276 times.
✓ Branch 1 taken 25567993 times.
29829269 for(int32_t i=0; i<6; i++)
22319 {
22320 25567993 cmb = &combobuf[MAPCOMBO2(i,bx,by)];
22321
4/6
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 25567766 times.
✓ Branch 2 taken 227 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 227 times.
25567993 if(combobuf[MAPCOMBO2(i,bx,by)].type==type && !(cmb->only_gentrig) && _effectflag(bx,by,1, i))
22322 {
22323 227 found = MAPCOMBO2(i,bx,by);
22324
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 1069 times.
1296 for(int32_t j = i+1; j < 6; ++j)
22325 {
22326
2/2
✓ Branch 0 taken 530 times.
✓ Branch 1 taken 539 times.
1069 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22327 {
22328
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 530 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
530 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,j))
22329 {
22330 found = -1;
22331 break;
22332 }
22333 530 }
22334 else
22335 {
22336
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
539 if (combobuf[MAPCOMBO2(j,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,j))
22337 {
22338 found = -1;
22339 break;
22340 }
22341 }
22342 1069 }
22343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if(found>-1)
22344 {
22345 227 foundlayer = i+1;
22346 227 fx = bx; fy = by;
22347 227 break;
22348 }
22349 }
22350 25567766 cmb = &combobuf[MAPCOMBO2(i,bx2,by2)];
22351
4/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 25567752 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
25567766 if(combobuf[MAPCOMBO2(i,bx2,by2)].type==type && !(cmb->only_gentrig) && _effectflag(bx2,by2,1, i))
22352 {
22353 14 found = MAPCOMBO2(i,bx2,by2);
22354
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 40 times.
54 for(int32_t j = i+1; j < 6; ++j)
22355 {
22356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22357 {
22358 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,j))
22359 {
22360 found = -1;
22361 break;
22362 }
22363 }
22364 else
22365 {
22366
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
40 if (combobuf[MAPCOMBO2(j,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,j))
22367 {
22368 found = -1;
22369 break;
22370 }
22371 }
22372 40 }
22373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(found>-1)
22374 {
22375 14 foundlayer = i+1;
22376 14 fx = bx2; fy = by2;
22377 14 break;
22378 }
22379 }
22380 25567752 }
22381 4261517 }
22382
22383
2/2
✓ Branch 0 taken 4261276 times.
✓ Branch 1 taken 3045 times.
4264321 if(found<0) return;
22384 3045 cmb = &combobuf[found];
22385
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2819 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 22 times.
✓ Branch 4 taken 78 times.
3045 switch(dir)
22386 {
22387 case up:
22388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2819 times.
2819 if(cmb->usrflags&cflag10)
22389 return;
22390 2819 break;
22391 case down:
22392
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 57 times.
126 if(cmb->usrflags&cflag9)
22393 69 return;
22394 57 break;
22395 case left:
22396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if(cmb->usrflags&cflag12)
22397 return;
22398 22 break;
22399 case right:
22400
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 17 times.
78 if(cmb->usrflags&cflag11)
22401 61 return;
22402 17 break;
22403 }
22404 2915 int32_t intbtn = cmb->attribytes[2];
22405
22406
2/2
✓ Branch 0 taken 2786 times.
✓ Branch 1 taken 129 times.
2915 if(intbtn) //
22407 {
22408
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 2700 times.
2786 if(cmb->usrflags & cflag13) //display prompt
22409 {
22410 2700 int altcmb = cmb->attributes[2]/10000;
22411 2700 prompt_combo = cmb->attributes[1]/10000;
22412
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2700 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2700 if(altcmb && ((islocked && !can_locked_combo(*cmb))
22413 || (isbosslocked && !(game->lvlitems[dlevel]&liBOSSKEY))))
22414 prompt_combo = altcmb;
22415 2700 prompt_cset = cmb->attribytes[4];
22416 2700 prompt_x = cmb->attrishorts[0];
22417 2700 prompt_y = cmb->attrishorts[1];
22418 2700 }
22419
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 2720 times.
2786 if(!getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK))
22420 {
22421 2720 return; //Button not pressed
22422 }
22423 66 }
22424
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9 times.
129 else if(pushing < 8 || pushing % 8) return; //Not pushing against chest enough
22425
22426
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 21 times.
75 if(ischest)
22427 {
22428
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if (!trigger_chest(get_rpos_handle_for_world_xy(fx, fy, foundlayer))) return;
22429 54 }
22430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 else if(islockblock)
22431 {
22432
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 18 times.
21 if (!trigger_lockblock(get_rpos_handle_for_world_xy(fx, fy, foundlayer))) return;
22433 18 }
22434
4/4
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 59 times.
72 if(intbtn && (cmb->usrflags & cflag13))
22435 59 prompt_combo = 0;
22436 4294074 }
22437
22438 16825418 void HeroClass::checkgenpush(rpos_t rpos)
22439 {
22440
2/2
✓ Branch 0 taken 16789225 times.
✓ Branch 1 taken 36193 times.
16825418 if (rpos == rpos_t::None)
22441 36193 return;
22442
22443
2/2
✓ Branch 0 taken 16789225 times.
✓ Branch 1 taken 117524575 times.
134313800 for (int layer = 0; layer < 7; ++layer)
22444 {
22445 117524575 auto rpos_handle = get_rpos_handle(rpos, layer);
22446
1/2
✓ Branch 0 taken 117524575 times.
✗ Branch 1 not taken.
120813706 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
22447
2/2
✓ Branch 0 taken 3287521 times.
✓ Branch 1 taken 1610 times.
3289131 if(!trig.trigger_flags.get(TRIGFLAG_PUSH)) return false;
22448
3/4
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
1610 return pushing && !(pushing % zc_max(1,trig.trig_pushtime));
22449 3289131 });
22450 117524575 }
22451 16825418 }
22452
22453 14284686 void HeroClass::checkgenpush()
22454 {
22455 14284686 zfix bx, by;
22456 14284686 zfix bx2, by2;
22457
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3503300 times.
✓ Branch 2 taken 2838925 times.
✓ Branch 3 taken 3833437 times.
✓ Branch 4 taken 4109024 times.
14284686 switch(dir)
22458 {
22459 case up:
22460 3503300 by = y + (bigHitbox ? -2 : 6);
22461 3503300 by2 = by;
22462 3503300 bx = x + 4;
22463 3503300 bx2 = bx + 8;
22464 3503300 break;
22465 case down:
22466 2838925 by = y + 17;
22467 2838925 by2 = by;
22468 2838925 bx = x + 4;
22469 2838925 bx2 = bx + 8;
22470 2838925 break;
22471 case left:
22472 3833437 by = y + (bigHitbox ? 0 : 8);
22473 3833437 by2 = y + 8;
22474 3833437 bx = x - 2;
22475 3833437 bx2 = x - 2;
22476 3833437 break;
22477 case right:
22478 4109024 by = y + (bigHitbox ? 0 : 8);
22479 4109024 by2 = y + 8;
22480 4109024 bx = x + 17;
22481 4109024 bx2 = x + 17;
22482 4109024 break;
22483 }
22484
22485 14284686 rpos_t rpos_1 = COMBOPOS_REGION_B(bx, by);
22486 14284686 rpos_t rpos_2 = COMBOPOS_REGION_B(bx2, by2);
22487 14284686 checkgenpush(rpos_1);
22488
2/2
✓ Branch 0 taken 11743954 times.
✓ Branch 1 taken 2540732 times.
14284686 if (rpos_1 != rpos_2) checkgenpush(rpos_2);
22489
22490
2/2
✓ Branch 0 taken 13281875 times.
✓ Branch 1 taken 1002811 times.
14284686 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
22491 {
22492 3537447 for_some_ffcs([&](const ffc_handle_t& ffc_handle) {
22493
4/4
✓ Branch 0 taken 2503201 times.
✓ Branch 1 taken 31435 times.
✓ Branch 2 taken 1268 times.
✓ Branch 3 taken 2501933 times.
2534636 if (ffcIsAt(ffc_handle, bx, by) || ffcIsAt(ffc_handle, bx2, by2))
22494 {
22495
1/2
✓ Branch 0 taken 32703 times.
✗ Branch 1 not taken.
33306 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
22496
1/2
✓ Branch 0 taken 603 times.
✗ Branch 1 not taken.
603 if(!trig.trigger_flags.get(TRIGFLAG_PUSH)) return false;
22497 return pushing && !(pushing % zc_max(1,trig.trig_pushtime));
22498 603 });
22499 32703 }
22500 2534636 return true;
22501 });
22502 1002811 }
22503 14284686 }
22504
22505 14284688 void HeroClass::checksigns() //Also checks for generic trigger buttons
22506 {
22507
5/6
✓ Branch 0 taken 14269735 times.
✓ Branch 1 taken 14953 times.
✓ Branch 2 taken 14250612 times.
✓ Branch 3 taken 19123 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14250612 times.
14284688 if(toogam || z>0 || fakez>0) return;
22508
5/6
✓ Branch 0 taken 14134630 times.
✓ Branch 1 taken 115982 times.
✓ Branch 2 taken 240882 times.
✓ Branch 3 taken 13893748 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 240882 times.
14250612 if(msg_active || (msg_onscreen && get_qr(qr_MSGDISAPPEAR)))
22509 115982 return; //Don't overwrite a message waiting to be dismissed
22510 14134630 zfix bx, by;
22511 14134630 zfix bx2, by2;
22512 14134630 zfix fx(-1), fy(-1);
22513
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3405176 times.
✓ Branch 2 taken 2827514 times.
✓ Branch 3 taken 3817449 times.
✓ Branch 4 taken 4084491 times.
14134630 switch(dir)
22514 {
22515 case up:
22516 3405176 by = y + (bigHitbox ? -2 : 6);
22517 3405176 by2 = by;
22518 3405176 bx = x + 4;
22519 3405176 bx2 = bx + 8;
22520 3405176 break;
22521 case down:
22522 2827514 by = y + 17;
22523 2827514 by2 = by;
22524 2827514 bx = x + 4;
22525 2827514 bx2 = bx + 8;
22526 2827514 break;
22527 case left:
22528 3817449 by = y + (bigHitbox ? 0 : 8);
22529 3817449 by2 = y + 8;
22530 3817449 bx = x - 2;
22531 3817449 bx2 = x - 2;
22532 3817449 break;
22533 case right:
22534 4084491 by = y + (bigHitbox ? 0 : 8);
22535 4084491 by2 = y + 8;
22536 4084491 bx = x + 17;
22537 4084491 bx2 = x + 17;
22538 4084491 break;
22539 }
22540
22541 14134630 int32_t found = -1;
22542 14134630 int32_t found_screen = -1;
22543 14134630 std::optional<ffc_handle_t> foundffc;
22544 14134630 int32_t found_lyr = 0;
22545 14134630 bool found_sign = false;
22546 14134630 int32_t tmp_cid = MAPCOMBO(bx, by);
22547 14134630 int32_t screen = get_screen_for_world_xy(bx, by);
22548 14134630 newcombo const* tmp_cmb = &combobuf[tmp_cid];
22549 14134630 bool has_trigger_button = false;
22550
2/2
✓ Branch 0 taken 14128894 times.
✓ Branch 1 taken 392851 times.
14521745 for(auto& trig : tmp_cmb->triggers)
22551
2/2
✓ Branch 0 taken 387115 times.
✓ Branch 1 taken 5736 times.
392851 if(trig.triggerbtn)
22552 {
22553 5736 has_trigger_button = true;
22554 5736 break;
22555 }
22556
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 14134608 times.
14140388 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22557
2/2
✓ Branch 0 taken 5758 times.
✓ Branch 1 taken 14128872 times.
14134630 || has_trigger_button) && _effectflag(bx,by,1, -1))
22558 {
22559 5758 found = tmp_cid;
22560 5758 found_screen = screen;
22561 5758 fx = bx; fy = by;
22562
2/2
✓ Branch 0 taken 11516 times.
✓ Branch 1 taken 5758 times.
17274 for (int32_t i = 0; i <= 1; ++i)
22563 {
22564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11516 times.
11516 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22565 {
22566 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,i)) found = -1;
22567 }
22568 else
22569 {
22570
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11516 if (combobuf[MAPCOMBO2(i,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,i)) found = -1;
22571 }
22572 11516 }
22573 5758 }
22574 14134630 tmp_cid = MAPCOMBO(bx2,by2);
22575 14134630 screen = get_screen_for_world_xy(bx2, by2);
22576 14134630 tmp_cmb = &combobuf[tmp_cid];
22577 14134630 has_trigger_button = false;
22578
2/2
✓ Branch 0 taken 14128410 times.
✓ Branch 1 taken 393989 times.
14522399 for(auto& trig : tmp_cmb->triggers)
22579
2/2
✓ Branch 0 taken 387769 times.
✓ Branch 1 taken 6220 times.
393989 if(trig.triggerbtn)
22580 {
22581 6220 has_trigger_button = true;
22582 6220 break;
22583 }
22584
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 14134608 times.
14140872 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22585
2/2
✓ Branch 0 taken 6242 times.
✓ Branch 1 taken 14128388 times.
14134630 || has_trigger_button) && _effectflag(bx2,by2,1, -1))
22586 {
22587 6242 found = tmp_cid;
22588 6242 found_screen = screen;
22589 6242 fx = bx2; fy = by2;
22590
2/2
✓ Branch 0 taken 12484 times.
✓ Branch 1 taken 6242 times.
18726 for (int32_t i = 0; i <= 1; ++i)
22591 {
22592
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12484 times.
12484 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22593 {
22594 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,i)) found = -1;
22595 }
22596 else
22597 {
22598
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12484 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12484 if (combobuf[MAPCOMBO2(i,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,i)) found = -1;
22599 }
22600 12484 }
22601 6242 }
22602
22603
2/2
✓ Branch 0 taken 13138926 times.
✓ Branch 1 taken 995704 times.
14134630 if (!get_qr(qr_OLD_FFC_FUNCTIONALITY))
22604 {
22605 3264863 foundffc = find_ffc([&](const ffc_handle_t& ffc_handle) {
22606
4/4
✓ Branch 0 taken 2237969 times.
✓ Branch 1 taken 31190 times.
✓ Branch 2 taken 1268 times.
✓ Branch 3 taken 2236701 times.
2269159 if (ffcIsAt(ffc_handle, bx, by) || ffcIsAt(ffc_handle, bx2, by2))
22607 {
22608 32458 tmp_cmb = &ffc_handle.combo();
22609 32458 has_trigger_button = false;
22610
2/2
✓ Branch 0 taken 32458 times.
✓ Branch 1 taken 603 times.
33061 for(auto& trig : tmp_cmb->triggers)
22611
1/2
✓ Branch 0 taken 603 times.
✗ Branch 1 not taken.
603 if(trig.triggerbtn)
22612 {
22613 has_trigger_button = true;
22614 break;
22615 }
22616
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32458 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32458 times.
32458 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22617 32458 || has_trigger_button) && true) //!TODO: FFC effect flag?
22618 {
22619 return true;
22620 }
22621 32458 }
22622
22623 2269159 return false;
22624 2269159 });
22625 995704 }
22626
22627
3/4
✓ Branch 0 taken 14128207 times.
✓ Branch 1 taken 6423 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14128207 times.
14134630 if(found<0 && !foundffc)
22628 {
22629 14128207 screen = get_screen_for_world_xy(bx, by);
22630
2/2
✓ Branch 0 taken 14126111 times.
✓ Branch 1 taken 84759461 times.
98885572 for(int32_t i=0; i<6; i++)
22631 {
22632 84759461 tmp_cid = MAPCOMBO2(i,bx,by);
22633 84759461 tmp_cmb = &combobuf[tmp_cid];
22634 84759461 has_trigger_button = false;
22635
2/2
✓ Branch 0 taken 84758112 times.
✓ Branch 1 taken 2457956 times.
87216068 for(auto& trig : tmp_cmb->triggers)
22636
2/2
✓ Branch 0 taken 2456607 times.
✓ Branch 1 taken 1349 times.
2457956 if(trig.triggerbtn)
22637 {
22638 1349 has_trigger_button = true;
22639 1349 break;
22640 }
22641
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 84758767 times.
84761504 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22642
2/2
✓ Branch 0 taken 2043 times.
✓ Branch 1 taken 84757418 times.
84759461 || has_trigger_button) && _effectflag(bx,by,1, i))
22643 {
22644 2043 found = tmp_cid;
22645 2043 found_screen = screen;
22646 2043 found_lyr = i+1;
22647 2043 fx = bx; fy = by;
22648
2/2
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 1382 times.
2043 if (i == 0)
22649 {
22650
2/2
✓ Branch 0 taken 1144 times.
✓ Branch 1 taken 238 times.
1382 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22651 {
22652
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1144 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1144 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && !_walkflag_layer(bx,by,1)) found = -1;
22653 1144 }
22654 else
22655 {
22656
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 238 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
238 if (combobuf[MAPCOMBO2(1,bx,by)].type == cBRIDGE && _effectflag_layer(bx,by,1)) found = -1;
22657 }
22658 1382 }
22659 2043 }
22660 84759461 screen = get_screen_for_world_xy(bx2, by2);
22661 84759461 tmp_cid = MAPCOMBO2(i,bx2,by2);
22662 84759461 tmp_cmb = &combobuf[tmp_cid];
22663 84759461 has_trigger_button = false;
22664
2/2
✓ Branch 0 taken 84758211 times.
✓ Branch 1 taken 2455890 times.
87214101 for(auto& trig : tmp_cmb->triggers)
22665
2/2
✓ Branch 0 taken 2454640 times.
✓ Branch 1 taken 1250 times.
2455890 if(trig.triggerbtn)
22666 {
22667 1250 has_trigger_button = true;
22668 1250 break;
22669 }
22670
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 84758775 times.
84761397 if(((tmp_cmb->type==cSIGNPOST && !(tmp_cmb->only_gentrig))
22671
2/2
✓ Branch 0 taken 1936 times.
✓ Branch 1 taken 84757525 times.
84759461 || has_trigger_button) && _effectflag(bx2,by2,1, i))
22672 {
22673 1936 found = tmp_cid;
22674 1936 found_screen = screen;
22675 1936 found_lyr = i+1;
22676 1936 fx = bx2; fy = by2;
22677
2/2
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 1283 times.
1936 if (i == 0)
22678 {
22679
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 251 times.
1283 if (get_qr(qr_OLD_BRIDGE_COMBOS))
22680 {
22681
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1032 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && !_walkflag_layer(bx2,by2,1)) found = -1;
22682 1032 }
22683 else
22684 {
22685
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
251 if (combobuf[MAPCOMBO2(1,bx2,by2)].type == cBRIDGE && _effectflag_layer(bx2,by2,1)) found = -1;
22686 }
22687 1283 }
22688 1936 }
22689
2/2
✓ Branch 0 taken 84757365 times.
✓ Branch 1 taken 2096 times.
84759461 if(found>-1) break;
22690 84757365 }
22691 14128207 }
22692
22693
3/4
✓ Branch 0 taken 14126111 times.
✓ Branch 1 taken 8519 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14126111 times.
14134630 if(found<0&&!foundffc) return;
22694
22695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8519 times.
8519 newcombo const& cmb = combobuf[foundffc ? foundffc->data() : found];
22696
22697 8519 byte signInput = 0;
22698 8519 bool didsign = false, didprompt = false;
22699
3/4
✓ Branch 0 taken 754 times.
✓ Branch 1 taken 7765 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 754 times.
8540 if(cmb.type == cSIGNPOST && !(cmb.only_gentrig))
22700 {
22701
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 599 times.
✓ Branch 2 taken 116 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 35 times.
754 switch(dir)
22702 {
22703 case up:
22704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 599 times.
599 if(cmb.usrflags&cflag10)
22705 goto endsigns;
22706 599 break;
22707 case down:
22708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116 times.
116 if(cmb.usrflags&cflag9)
22709 goto endsigns;
22710 116 break;
22711 case left:
22712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(cmb.usrflags&cflag12)
22713 goto endsigns;
22714 4 break;
22715 case right:
22716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if(cmb.usrflags&cflag11)
22717 goto endsigns;
22718 35 break;
22719 }
22720 754 int32_t intbtn = cmb.attribytes[2];
22721
22722
1/2
✓ Branch 0 taken 754 times.
✗ Branch 1 not taken.
754 if(intbtn) //
22723 {
22724 754 signInput = getIntBtnInput(intbtn, INPUT_PRESS | INPUT_DRUNK);
22725
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 733 times.
754 if(!signInput)
22726 {
22727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 733 times.
733 if(cmb.usrflags & cflag13) //display prompt
22728 {
22729 733 prompt_combo = cmb.attributes[1]/10000;
22730 733 prompt_cset = cmb.attribytes[4];
22731 733 prompt_x = cmb.attrishorts[0];
22732 733 prompt_y = cmb.attrishorts[1];
22733 733 didprompt = true;
22734 733 }
22735 733 goto endsigns; //Button not pressed
22736 }
22737 21 }
22738 else if(pushing < 8 || pushing%8) goto endsigns; //Not pushing against sign enough
22739
22740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 trigger_sign(cmb, foundffc ? foundffc->screen : found_screen);
22741 21 didsign = true;
22742 21 }
22743 endsigns:
22744 8519 auto& cpos = cpos_get(get_rpos_handle_for_world_xy(fx, fy, found_lyr));
22745 int dir_trigflag;
22746
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✓ Branch 2 taken 6674 times.
✓ Branch 3 taken 802 times.
✓ Branch 4 taken 520 times.
8519 switch(dir)
22747 {
22748 case down:
22749 523 dir_trigflag = TRIGFLAG_BTN_TOP;
22750 523 break;
22751 case up:
22752 6674 dir_trigflag = TRIGFLAG_BTN_BOTTOM;
22753 6674 break;
22754 case right:
22755 802 dir_trigflag = TRIGFLAG_BTN_LEFT;
22756 802 break;
22757 case left:
22758 520 dir_trigflag = TRIGFLAG_BTN_RIGHT;
22759 520 break;
22760 }
22761 8519 bool found_a_trigger_dir = false, did_trigger = false;
22762 8519 combined_handle_t comb_handle;
22763
2/4
✓ Branch 0 taken 8519 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8519 times.
8519 if(fx != -1 && fy != -1)
22764 8519 comb_handle = get_rpos_handle_for_world_xy(fx, fy, found_lyr);
22765
1/2
✓ Branch 0 taken 8519 times.
✗ Branch 1 not taken.
8519 if(foundffc)
22766 comb_handle = foundffc.value();
22767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8519 times.
16284 did_trigger = trig_each_combo_trigger(comb_handle, [&](combo_trigger const& trig, size_t idx){
22768
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 7690 times.
7765 if(!trig.trigger_flags.get(dir_trigflag)) return false;
22769 7690 found_a_trigger_dir = true;
22770 7690 auto& trig_data = cpos.trig_data[idx];
22771
3/6
✓ Branch 0 taken 7690 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7690 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7690 times.
7690 if(fx != -1 && fy != -1 && trig_data.cooldown) return false;
22772
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7690 times.
✓ Branch 2 taken 7513 times.
✓ Branch 3 taken 177 times.
15380 return trig.triggerbtn && (getIntBtnInput(trig.triggerbtn, INPUT_PRESS | INPUT_DRUNK) || checkIntBtnVal(trig.triggerbtn, signInput));
22773 7765 });
22774
5/6
✓ Branch 0 taken 7688 times.
✓ Branch 1 taken 831 times.
✓ Branch 2 taken 7688 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 175 times.
✓ Branch 5 taken 7513 times.
8519 if(!found_a_trigger_dir || didprompt || did_trigger)
22775 1006 return;
22776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7513 times.
7513 else if(cmb.type == cBUTTONPROMPT)
22777 {
22778 prompt_combo = cmb.attributes[0]/10000;
22779 prompt_cset = cmb.attribytes[0];
22780 prompt_x = cmb.attrishorts[0];
22781 prompt_y = cmb.attrishorts[1];
22782 }
22783
2/2
✓ Branch 0 taken 1362 times.
✓ Branch 1 taken 7513 times.
8875 else for (size_t idx = 0; idx < cmb.triggers.size(); ++idx)
22784 {
22785 7513 auto& trig_data = cpos.trig_data[idx];
22786
3/6
✓ Branch 0 taken 7513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7513 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7513 times.
✗ Branch 5 not taken.
7513 if(fx != -1 && fy != -1 && trig_data.cooldown) continue;
22787 7513 auto& trig = cmb.triggers[idx];
22788 7513 bool cond = check_trig_conditions(comb_handle, idx);
22789
2/2
✓ Branch 0 taken 7333 times.
✓ Branch 1 taken 180 times.
7513 auto pcid = cond ? trig.prompt_cid : trig.fail_prompt_cid;
22790
2/2
✓ Branch 0 taken 7333 times.
✓ Branch 1 taken 180 times.
7513 auto pcs = cond ? trig.prompt_cs : trig.fail_prompt_cs;
22791
2/2
✓ Branch 0 taken 1362 times.
✓ Branch 1 taken 6151 times.
7513 if(pcid)
22792 {
22793 6151 prompt_combo = pcid;
22794 6151 prompt_cset = pcs;
22795 6151 prompt_x = trig.prompt_x;
22796 6151 prompt_y = trig.prompt_y;
22797 6151 break;
22798 }
22799 1362 }
22800 14284688 }
22801
22802 // Checks for locked doors, and potentially unlocks them.
22803 // Only looks at `current_screen`.
22804 14283256 void HeroClass::checklocked()
22805 {
22806
2/2
✓ Branch 0 taken 14953 times.
✓ Branch 1 taken 14268303 times.
14283256 if(toogam) return; //Walk through walls.
22807
2/2
✓ Branch 0 taken 8012302 times.
✓ Branch 1 taken 6256001 times.
14268303 if(!isdungeon(current_screen)) return;
22808
4/4
✓ Branch 0 taken 6203749 times.
✓ Branch 1 taken 52252 times.
✓ Branch 2 taken 12798 times.
✓ Branch 3 taken 6190951 times.
6256001 if( !diagonalMovement && pushing!=8) return;
22809 //This is required to allow the player to open a door, while sliding along a wall (pressing in the direction of the door, and sliding left or right)
22810
4/4
✓ Branch 0 taken 52252 times.
✓ Branch 1 taken 12798 times.
✓ Branch 2 taken 2677 times.
✓ Branch 3 taken 49575 times.
65050 if ( diagonalMovement && pushing < 8 ) return; //Allow wall walking Should I add a quest rule for this? -Z
22811
22812 46425 auto [offx, offy] = translate_screen_coordinates_to_world(current_screen);
22813 30950 int x = this->x - offx;
22814 30950 int y = this->y - offy;
22815
22816 15475 optional<int> openDir;
22817
4/6
✓ Branch 0 taken 12798 times.
✓ Branch 1 taken 2677 times.
✓ Branch 2 taken 12798 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12798 times.
15475 if ( diagonalMovement || NO_GRIDLOCK)
22818 {
22819
8/8
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 2533 times.
✓ Branch 2 taken 98 times.
✓ Branch 3 taken 46 times.
✓ Branch 4 taken 57 times.
✓ Branch 5 taken 41 times.
✓ Branch 6 taken 25 times.
✓ Branch 7 taken 32 times.
2677 if(y <= 32 && x >= 112 && x <= 128 && Y_DIR(dir) == up)
22820 32 openDir = up;
22821
8/8
✓ Branch 0 taken 321 times.
✓ Branch 1 taken 2324 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 90 times.
✓ Branch 5 taken 108 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 33 times.
2645 else if(y >= 128 && x >= 112 && x <= 128 && Y_DIR(dir) == down)
22822 33 openDir = down;
22823
5/8
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 1149 times.
✓ Branch 2 taken 272 times.
✓ Branch 3 taken 1191 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 272 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2612 else if(y > 72 && y < 88 && x <= 32 && X_DIR(dir) == left)
22824 openDir = left;
22825
5/8
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 1149 times.
✓ Branch 2 taken 272 times.
✓ Branch 3 taken 1191 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 272 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2612 else if(y > 72 && y < 88 && x >= 208 && X_DIR(dir) == right)
22826 openDir = right;
22827 2677 }
22828 else
22829 {
22830
6/6
✓ Branch 0 taken 1751 times.
✓ Branch 1 taken 11047 times.
✓ Branch 2 taken 474 times.
✓ Branch 3 taken 1277 times.
✓ Branch 4 taken 61 times.
✓ Branch 5 taken 413 times.
12798 if(y <= 32 && x == 120 && Y_DIR(dir) == up)
22831 413 openDir = up;
22832
6/6
✓ Branch 0 taken 1806 times.
✓ Branch 1 taken 10579 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 1554 times.
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 227 times.
12385 else if(y >= 128 && x == 120 && Y_DIR(dir) == down)
22833 227 openDir = down;
22834
6/6
✓ Branch 0 taken 1831 times.
✓ Branch 1 taken 10327 times.
✓ Branch 2 taken 339 times.
✓ Branch 3 taken 1492 times.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 225 times.
12158 else if(y == 80 && x <= 32 && X_DIR(dir) == left)
22835 225 openDir = left;
22836
6/6
✓ Branch 0 taken 1606 times.
✓ Branch 1 taken 10327 times.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 1183 times.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 356 times.
11933 else if(y == 80 && x >= 208 && X_DIR(dir) == right)
22837 356 openDir = right;
22838 }
22839
22840
2/2
✓ Branch 0 taken 14189 times.
✓ Branch 1 taken 1286 times.
15475 if(openDir)
22841 {
22842 1286 int d = *openDir;
22843
2/2
✓ Branch 0 taken 364 times.
✓ Branch 1 taken 922 times.
1286 if (hero_scr->door[d]==dLOCKED)
22844 {
22845
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 14 times.
364 if(usekey())
22846 {
22847 350 putdoor(hero_scr, scrollbuf, d, dUNLOCKED);
22848 350 hero_scr->door[d]=dUNLOCKED;
22849 350 set_doorstate(current_screen, d);
22850 350 sfx(WAV_DOOR);
22851 350 markBmap();
22852
22853 // set_doorstate updates the door state of the opposite screen too, but it doesn't
22854 // update anything for the current region. Do that here.
22855
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if (mapscr* opp_scr = get_scr_current_region_dir(current_screen, (direction)d))
22856 {
22857 if (opp_scr->door[d^1] == dLOCKED)
22858 {
22859 opp_scr->door[d^1] = dUNLOCKED;
22860 putdoor(opp_scr, scrollbuf, d^1, dUNLOCKED);
22861 }
22862 }
22863 350 }
22864 14 else return;
22865 350 }
22866
2/2
✓ Branch 0 taken 866 times.
✓ Branch 1 taken 56 times.
922 else if(hero_scr->door[d]==dBOSS)
22867 {
22868
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 5 times.
56 if(game->lvlitems[dlevel]&liBOSSKEY)
22869 {
22870 51 putdoor(hero_scr, scrollbuf, d, dOPENBOSS);
22871 51 hero_scr->door[d]=dOPENBOSS;
22872 51 set_doorstate(current_screen, d);
22873 51 sfx(WAV_DOOR);
22874 51 markBmap();
22875
22876 // set_doorstate updates the door state of the opposite screen too, but it doesn't
22877 // update anything for the current region. Do that here.
22878
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if (mapscr* opp_scr = get_scr_current_region_dir(current_screen, (direction)d))
22879 {
22880 if (opp_scr->door[d^1] == dBOSS)
22881 {
22882 opp_scr->door[d^1] = dOPENBOSS;
22883 putdoor(opp_scr, scrollbuf, d^1, dOPENBOSS);
22884 }
22885 }
22886
22887 // Run Boss Key Script
22888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3468 times.
3468 for ( int32_t q = 0; q < MAXITEMS; ++q )
22889
2/2
✓ Branch 0 taken 3417 times.
✓ Branch 1 taken 51 times.
3468 if ( itemsbuf[q].type == itype_bosskey )
22890 {
22891
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
51 if (itemsbuf[q].script && !(FFCore.doscript(ScriptType::Item, q) && get_qr(qr_ITEMSCRIPTSKEEPRUNNING)))
22892 {
22893 FFCore.reset_script_engine_data(ScriptType::Item, q);
22894 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[q].script, q);
22895 FFCore.deallocateAllScriptOwned(ScriptType::Item, q);
22896 }
22897 51 break;
22898 }
22899 51 }
22900 5 else return;
22901 51 }
22902 1267 }
22903 14283256 }
22904
22905 14283256 void HeroClass::checkswordtap()
22906 {
22907
6/6
✓ Branch 0 taken 6928894 times.
✓ Branch 1 taken 7354362 times.
✓ Branch 2 taken 40969 times.
✓ Branch 3 taken 6887925 times.
✓ Branch 4 taken 40006 times.
✓ Branch 5 taken 963 times.
14283256 if(attack!=wSword || charging<=0 || pushing<8) return;
22908
22909 963 int32_t bx=x;
22910 963 int32_t by=y+8;
22911
22912
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 307 times.
✓ Branch 4 taken 262 times.
963 switch(dir)
22913 {
22914 case up:
22915
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 65 times.
282 if (!getInput(btnUp, INPUT_HERO_ACTION)) return;
22916
22917 217 by-=16;
22918 217 break;
22919
22920 case down:
22921
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 20 times.
112 if (!getInput(btnDown, INPUT_HERO_ACTION)) return;
22922
22923 92 by+=16;
22924 92 bx+=8;
22925 92 break;
22926
22927 case left:
22928
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 139 times.
307 if (!getInput(btnLeft, INPUT_HERO_ACTION)) return;
22929
22930 168 bx-=16;
22931 168 by+=8;
22932 168 break;
22933
22934 case right:
22935
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 72 times.
262 if (!getInput(btnRight, INPUT_HERO_ACTION)) return;
22936
22937 190 bx+=16;
22938 190 by+=8;
22939 190 break;
22940 }
22941
22942
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 667 times.
✓ Branch 4 taken 513 times.
✓ Branch 5 taken 154 times.
667 if(!_walkflag(bx,by,0,STANDING_Z_STATE)) return;
22943
22944 513 attackclk=SWORDTAPFRAME;
22945 513 pushing=-8; //16 frames between taps
22946 513 tapping=true;
22947
22948
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 500 times.
513 if (!isCuttableType(COMBOTYPE(bx, by)))
22949 {
22950 500 int tap_sfx = -1;
22951 500 bool hollow = false;
22952
2/2
✓ Branch 0 taken 500 times.
✓ Branch 1 taken 3500 times.
4000 for(int lyr = 6; lyr >= 0; --lyr)
22953 {
22954 3500 auto rpos_handle_lyr = get_rpos_handle_for_world_xy(bx, by, lyr);
22955 3500 auto& cmb = rpos_handle_lyr.combo();
22956
1/2
✓ Branch 0 taken 3500 times.
✗ Branch 1 not taken.
3500 if(cmb.sfx_tap)
22957 {
22958 tap_sfx = cmb.sfx_tap;
22959 break;
22960 }
22961
22962
3/4
✓ Branch 0 taken 3491 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3491 times.
6991 if(rpos_handle_lyr.sflag() == mfBOMB || rpos_handle_lyr.sflag() == mfSBOMB
22963
2/4
✓ Branch 0 taken 3491 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3491 times.
✗ Branch 3 not taken.
3491 || cmb.flag == mfBOMB || cmb.flag == mfSBOMB)
22964 9 hollow = true;
22965 3500 }
22966
2/4
✓ Branch 0 taken 500 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500 times.
500 if(tap_sfx < 0 && get_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX))
22967 {
22968
4/12
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 491 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 491 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
500 if(hollow || (!is_in_scrolling_region() && origin_scr->door[dir]==dBOMB && ((dir==up||dir==down)
22969 ? (bx>=112 && bx<144 && (by>=144 || by<=32))
22970 : by>=72 && by<104 && (bx>=224 || bx<=32))))
22971 9 tap_sfx = QMisc.miscsfx[sfxTAP_HOLLOW];
22972 500 }
22973
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 491 times.
500 if(tap_sfx < 0)
22974 491 tap_sfx = QMisc.miscsfx[sfxTAP];
22975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 500 times.
500 if(tap_sfx)
22976 500 sfx(tap_sfx,pan(x));
22977 500 }
22978 14283256 }
22979
22980 27606 void HeroClass::fairycircle(int32_t type)
22981 {
22982
2/2
✓ Branch 0 taken 23253 times.
✓ Branch 1 taken 4353 times.
27606 if(fairyclk==0)
22983 {
22984
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4333 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 19 times.
4353 switch(type)
22985 {
22986 case REFILL_LIFE:
22987
2/2
✓ Branch 0 taken 4177 times.
✓ Branch 1 taken 156 times.
4333 if(didstuff&did_fairy) return;
22988
22989 156 didstuff|=did_fairy;
22990 156 break;
22991
22992 case REFILL_MAGIC:
22993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(didstuff&did_magic) return;
22994
22995 1 didstuff|=did_magic;
22996 1 break;
22997
22998 case REFILL_ALL:
22999
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 2 times.
19 if(didstuff&did_all) return;
23000
23001 2 didstuff|=did_all;
23002 2 }
23003
23004 159 refill_what=type;
23005 159 refill_why=REFILL_FAIRY;
23006 159 StartRefill(type);
23007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if (IsSideSwim()) {action=sideswimfreeze; FFCore.setHeroAction(sideswimfreeze);}
23008 159 else {action=freeze; FFCore.setHeroAction(freeze);}
23009 159 holdclk=0;
23010 159 hopclk=0;
23011 159 }
23012
23013 23412 ++fairyclk;
23014
23015
2/2
✓ Branch 0 taken 10557 times.
✓ Branch 1 taken 12855 times.
23412 if(refilling!=REFILL_FAIRYDONE)
23016 {
23017
2/2
✓ Branch 0 taken 10398 times.
✓ Branch 1 taken 159 times.
10557 if(!refill())
23018 159 refilling=REFILL_FAIRYDONE;
23019 10557 }
23020
23021
2/2
✓ Branch 0 taken 12697 times.
✓ Branch 1 taken 158 times.
12855 else if(++holdclk>80)
23022 {
23023 158 reset_swordcharge();
23024 158 attackclk=0;
23025 158 action=none; FFCore.setHeroAction(none);
23026 158 fairyclk=0;
23027 158 holdclk=0;
23028 158 refill_why = 0;
23029 158 refilling=REFILL_NONE;
23030 158 map_bkgsfx(true);
23031 158 }
23032 27606 }
23033
23034 1414084 int32_t touchcombo(int32_t x,int32_t y)
23035 {
23036
2/2
✓ Branch 0 taken 2828100 times.
✓ Branch 1 taken 1414016 times.
4242116 for (int32_t i = 0; i <= 1; ++i)
23037 {
23038
2/2
✓ Branch 0 taken 2623300 times.
✓ Branch 1 taken 204800 times.
2828100 if (get_qr(qr_OLD_BRIDGE_COMBOS))
23039 {
23040
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2623300 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2623300 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && !_walkflag_layer(x,y,i)) return 0;
23041 2623300 }
23042 else
23043 {
23044
4/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 204699 times.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 68 times.
204800 if (combobuf[MAPCOMBO2(i,x,y)].type == cBRIDGE && _effectflag_layer(x,y,i)) return 0;
23045 }
23046 2828032 }
23047
2/2
✓ Branch 0 taken 1412378 times.
✓ Branch 1 taken 1638 times.
1414016 if (!_effectflag(x,y,1, -1)) return 0;
23048 1412378 newcombo const& cmb = combobuf[MAPCOMBO(x,y)];
23049
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 1412330 times.
1412378 if(cmb.only_gentrig)
23050 48 return 0;
23051
3/3
✓ Branch 0 taken 3242 times.
✓ Branch 1 taken 1407137 times.
✓ Branch 2 taken 1951 times.
1412330 switch(cmb.type)
23052 {
23053 case cBSGRAVE:
23054 case cGRAVE:
23055
3/4
✓ Branch 0 taken 2255 times.
✓ Branch 1 taken 987 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2255 times.
3242 if(MAPFLAG(x,y)||MAPCOMBOFLAG(x,y)) //!DIMITODO: all flags break graves, not just push flags
23056 {
23057 987 break;
23058 }
23059
23060 [[fallthrough]];
23061 case cARMOS:
23062 {
23063 4206 return cmb.type;
23064 }
23065 }
23066
23067 1408124 return 0;
23068 1414084 }
23069
23070 static int32_t GridX(int32_t x)
23071 {
23072 return (x >> 4) << 4;
23073 }
23074
23075 //Snaps 'y' to the combo grid
23076 //Equivalent to calling ComboY(ComboAt(foo,y));
23077 static int32_t GridY(int32_t y)
23078 {
23079 return (y >> 4) << 4;
23080 }
23081
23082 9 static int32_t beamGrabComboFromPos(rpos_t rpos, int32_t type)
23083 {
23084
1/2
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
63 for (int lyr = 6; lyr >= 0; --lyr)
23085 {
23086 63 auto rpos_handle = get_rpos_handle(rpos, lyr);
23087
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 54 times.
63 if (rpos_handle.ctype() == type)
23088 9 return rpos_handle.data();
23089 54 }
23090
23091 return -1;
23092 9 }
23093
23094 typedef word spot_t;
23095 static std::vector<int32_t> typeMap;
23096 static std::vector<int32_t> customTypeMap;
23097 static std::vector<int32_t> istrig;
23098 // static std::map<int32_t, std::map<size_t, word>> MAPS_prism_dir_seen_map;
23099 static rpos_t beam_hero_rpos = rpos_t::None;
23100 static const int32_t SPTYPE_SOLID = -1;
23101 enum
23102 {
23103 beamoffs_gr, beamoffs_up, beamoffs_down, beamoffs_left, beamoffs_right,
23104 beamoffs_uleft, beamoffs_uright, beamoffs_dleft, beamoffs_dright, beamoffs_vert,
23105 beamoffs_horz, beamoffs_notup, beamoffs_notdown, beamoffs_notleft, beamoffs_notright,
23106 beamoffs_all, beamoffs_max
23107 };
23108 struct lightbeam_xy
23109 {
23110 int16_t x;
23111 int16_t y;
23112 lightbeam_xy(int32_t nx, int32_t ny)
23113 {
23114 x = vbound(nx,-32768,32767);
23115 y = vbound(ny,-32768,32767);
23116 }
23117 lightbeam_xy(dword ffpos)
23118 {
23119 x = int16_t(ffpos >> 16);
23120 y = int16_t(ffpos & 0xFFFF);
23121 }
23122 bool valid() const
23123 {
23124 return valid(x,y);
23125 }
23126 void bound()
23127 {
23128 x = vbound(x,0-16,world_w-1+16);
23129 y = vbound(y,0-16,world_h-1+16);
23130 }
23131 dword ffpos() const
23132 {
23133 return (word(x)<<16)|word(y&0xFFFF);
23134 }
23135 rpos_t pos() const
23136 {
23137 return COMBOPOS_REGION(vbound(x,0,world_w-1),vbound(y,0,world_h-1));
23138 }
23139 bool herocollide(byte beamwid)
23140 {
23141 int bx = x-beamwid/2, by = y-beamwid/2;
23142 int hx = Hero.x.getInt(), hy = Hero.y.getInt();
23143 return hx+15 >= bx && hx < bx+beamwid
23144 && hy+15 >= by && hy < by+beamwid;
23145 }
23146 static bool valid(int32_t x, int32_t y)
23147 {
23148 return x+16 >= 0 && x-16 < world_w && y+16 >= 0 && y-16 < world_h;
23149 }
23150 };
23151 #define SP_VISITED 0x1
23152 #define SP_FLAGS 0x01E
23153 #define SP_GOFLAGS 0x1E0
23154 #define SP_MASK (SP_VISITED|SP_FLAGS)
23155 #define SP_FLAG(dir) (0x2<<dir)
23156 #define SP_GOFLAG(dir) (0x20<<dir)
23157 #define BEAM_AGE_LIMIT 512
23158
23159 14283 static void handleBeam(spot_t* grid, size_t age, byte spotdir, rpos_t rpos, byte set, bool block, bool refl)
23160 {
23161
2/2
✓ Branch 0 taken 7620 times.
✓ Branch 1 taken 6663 times.
14283 if(spotdir > 3) return; //invalid dir
23162
23163 6663 int combos_wide = cur_region.screen_width * 16;
23164 6663 int combos_tall = cur_region.screen_height * 11;
23165
2/2
✓ Branch 0 taken 5429 times.
✓ Branch 1 taken 1234 times.
6663 int32_t trigflag = set ? (1 << (set-1)) : ~0;
23166 6663 bool doAge = true;
23167 6663 spot_t f = 0;
23168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70632 times.
70632 while (rpos < region_max_rpos)
23169 {
23170 140809 auto [x, y] = COMBOXY_REGION_INDEX(rpos);
23171
23172 70632 f = SP_GOFLAG(spotdir);
23173
2/2
✓ Branch 0 taken 70177 times.
✓ Branch 1 taken 455 times.
70632 if((grid[(int)rpos] & f) == f)
23174 455 return;
23175 70177 else grid[(int)rpos] |= f;
23176 70177 f = SP_FLAG(spotdir);
23177
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 70024 times.
70177 if((grid[(int)rpos] & f) != f)
23178 {
23179 70024 grid[(int)rpos] |= f;
23180 70024 istrig[(int)rpos] |= trigflag;
23181 70024 doAge = false;
23182 70024 age = 0;
23183 70024 }
23184
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 16931 times.
✓ Branch 2 taken 9603 times.
✓ Branch 3 taken 23595 times.
✓ Branch 4 taken 20048 times.
70177 switch(spotdir)
23185 {
23186 case up:
23187 16931 y -= 1;
23188 16931 break;
23189 case down:
23190 9603 y += 1;
23191 9603 break;
23192 case left:
23193 23595 x -= 1;
23194 23595 break;
23195 case right:
23196 20048 x += 1;
23197 20048 break;
23198 }
23199
23200
4/8
✓ Branch 0 taken 70177 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 70177 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 70177 times.
70177 if (!(x >= 0 && x < combos_wide && y >= 0 && y < combos_tall)) return;
23201
23202 140354 rpos = COMBOPOS_REGION_INDEX(x, y);
23203
23204
2/2
✓ Branch 0 taken 6208 times.
✓ Branch 1 taken 63969 times.
70177 switch (typeMap[(int)rpos])
23205 {
23206 case SPTYPE_SOLID: case cBLOCKALL:
23207 6208 return;
23208 }
23209
23210
3/6
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 63094 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 875 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
63969 if (rpos == beam_hero_rpos && block && spotdir == oppositeDir[Hero.getDir()])
23211 return;
23212
23213 63969 f = SP_FLAG(oppositeDir[spotdir]);
23214
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 63816 times.
63969 if((grid[(int)rpos] & f) != f)
23215 {
23216 63816 grid[(int)rpos] |= f;
23217 63816 istrig[(int)rpos] |= trigflag;
23218 63816 doAge = false;
23219 63816 age = 0;
23220 63816 }
23221
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 63816 times.
63969 if(doAge)
23222 {
23223
1/2
✓ Branch 0 taken 153 times.
✗ Branch 1 not taken.
153 if(++age > BEAM_AGE_LIMIT)
23224 return;
23225 153 }
23226 63816 else doAge = true;
23227
23228
4/4
✓ Branch 0 taken 875 times.
✓ Branch 1 taken 63094 times.
✓ Branch 2 taken 147 times.
✓ Branch 3 taken 728 times.
63969 if (rpos == beam_hero_rpos && refl)
23229 728 spotdir = Hero.getDir();
23230
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 9088 times.
✓ Branch 2 taken 7781 times.
✓ Branch 3 taken 46363 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
63241 else switch (typeMap[(int)rpos])
23231 {
23232 case cLIGHTTARGET:
23233 {
23234 9 int cid = beamGrabComboFromPos(rpos, cLIGHTTARGET);
23235
2/4
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
9 if(cid > -1 && combobuf[cid].usrflags&cflag3) //Blocks light
23236 return;
23237
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 6 times.
9 if(get_qr(qr_BROKEN_LIGHTBEAM_HITBOX))
23238 6 spotdir = oppositeDir[spotdir];
23239 9 break;
23240 }
23241 case cMIRROR:
23242 spotdir = oppositeDir[spotdir];
23243 break;
23244 case cMIRRORSLASH:
23245
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2991 times.
✓ Branch 2 taken 3402 times.
✓ Branch 3 taken 1726 times.
✓ Branch 4 taken 969 times.
9088 switch(spotdir)
23246 {
23247 case up:
23248 2991 spotdir = right; break;
23249 case right:
23250 3402 spotdir = up; break;
23251 case down:
23252 1726 spotdir = left; break;
23253 case left:
23254 969 spotdir = down; break;
23255 }
23256 9088 break;
23257 case cMIRRORBACKSLASH:
23258
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1927 times.
✓ Branch 2 taken 1814 times.
✓ Branch 3 taken 1522 times.
✓ Branch 4 taken 2518 times.
7781 switch(spotdir)
23259 {
23260 case up:
23261 1927 spotdir = left; break;
23262 case left:
23263 1814 spotdir = up; break;
23264 case down:
23265 1522 spotdir = right; break;
23266 case right:
23267 2518 spotdir = down; break;
23268 }
23269 7781 break;
23270 case cMAGICPRISM:
23271 for(byte d = 0; d < 4; ++d)
23272 {
23273 if(d == oppositeDir[spotdir]) continue;
23274 handleBeam(grid, age, d, rpos, set, block, refl);
23275 }
23276 return;
23277 case cMAGICPRISM4:
23278 for(byte d = 0; d < 4; ++d)
23279 {
23280 handleBeam(grid, age, d, rpos, set, block, refl);
23281 }
23282 return;
23283 case cMIRRORNEW:
23284 {
23285 auto cid = customTypeMap[(int)rpos];
23286 if(unsigned(cid) >= MAXCOMBOS) break;
23287 newcombo const& cmb = combobuf[cid];
23288 byte newdir = cmb.attribytes[spotdir];
23289 if(newdir > 7) return;
23290 if(newdir > 3) break;
23291 spotdir = newdir;
23292 break;
23293 }
23294 }
23295 }
23296 14283 }
23297
23298 static void handleFFBeam(std::map<dword,spot_t>& grid, size_t age, byte spotdir, lightbeam_xy curxy, byte set, bool block, bool refl, byte beamwid)
23299 {
23300 if(spotdir > 3) return; //invalid dir
23301 int32_t trigflag = set ? (1 << (set-1)) : ~0;
23302 bool doAge = true;
23303 byte f = 0;
23304 while(curxy.valid())
23305 {
23306 f = SP_FLAG(spotdir);
23307 if((grid[curxy.ffpos()] & f) != f)
23308 {
23309 grid[curxy.ffpos()] |= f;
23310 istrig[(int)curxy.pos()] |= trigflag;
23311 doAge = false;
23312 age = 0;
23313 }
23314 switch(spotdir)
23315 {
23316 case up:
23317 curxy.y -= 16;
23318 break;
23319 case down:
23320 curxy.y += 16;
23321 break;
23322 case left:
23323 curxy.x -= 16;
23324 break;
23325 case right:
23326 curxy.x += 16;
23327 break;
23328 }
23329 auto curpos = curxy.pos();
23330 switch(typeMap[(int)curpos])
23331 {
23332 case SPTYPE_SOLID: case cBLOCKALL:
23333 return;
23334 case cMIRRORNEW:
23335 {
23336 auto cid = customTypeMap[(int)curpos];
23337 if(unsigned(cid) >= MAXCOMBOS) break;
23338 newcombo const& cmb = combobuf[cid];
23339 byte newdir = cmb.attribytes[spotdir];
23340 if(newdir > 7) return;
23341 break;
23342 }
23343 }
23344 bool collided_hero = beam_hero_rpos != rpos_t::None && curxy.herocollide(beamwid);
23345 if(block && (spotdir == oppositeDir[Hero.getDir()]) && collided_hero)
23346 return;
23347
23348 f = SP_FLAG(oppositeDir[spotdir]);
23349 if((grid[curxy.ffpos()] & f) != f)
23350 {
23351 grid[curxy.ffpos()] |= f;
23352 istrig[(int)curpos] |= trigflag;
23353 doAge = false;
23354 age = 0;
23355 }
23356 if(!curxy.valid()) return;
23357 if(doAge)
23358 {
23359 if(++age > BEAM_AGE_LIMIT)
23360 return;
23361 }
23362 else doAge = true;
23363
23364 if(refl && collided_hero)
23365 spotdir = Hero.getDir();
23366 else switch(typeMap[(int)curpos])
23367 {
23368 case cLIGHTTARGET:
23369 {
23370 int cid = beamGrabComboFromPos(curpos, cLIGHTTARGET);
23371 if(cid > -1 && combobuf[cid].usrflags&cflag3) //Blocks light
23372 return;
23373 if(get_qr(qr_BROKEN_LIGHTBEAM_HITBOX))
23374 spotdir = oppositeDir[spotdir];
23375 break;
23376 }
23377 case cMIRROR:
23378 spotdir = oppositeDir[spotdir];
23379 break;
23380 case cMIRRORSLASH:
23381 switch(spotdir)
23382 {
23383 case up:
23384 spotdir = right; break;
23385 case right:
23386 spotdir = up; break;
23387 case down:
23388 spotdir = left; break;
23389 case left:
23390 spotdir = down; break;
23391 }
23392 break;
23393 case cMIRRORBACKSLASH:
23394 switch(spotdir)
23395 {
23396 case up:
23397 spotdir = left; break;
23398 case left:
23399 spotdir = up; break;
23400 case down:
23401 spotdir = right; break;
23402 case right:
23403 spotdir = down; break;
23404 }
23405 break;
23406 case cMAGICPRISM:
23407 for(byte d = 0; d < 4; ++d)
23408 {
23409 if(d == oppositeDir[spotdir]) continue;
23410 handleFFBeam(grid, age, d, curxy, set, block, refl, beamwid);
23411 }
23412 return;
23413 case cMAGICPRISM4:
23414 for(byte d = 0; d < 4; ++d)
23415 {
23416 handleFFBeam(grid, age, d, curxy, set, block, refl, beamwid);
23417 }
23418 return;
23419 case cMIRRORNEW:
23420 {
23421 auto cid = customTypeMap[(int)curpos];
23422 if(unsigned(cid) >= MAXCOMBOS) break;
23423 newcombo const& cmb = combobuf[cid];
23424 byte newdir = cmb.attribytes[spotdir];
23425 if(newdir > 3) break;
23426 spotdir = newdir;
23427 break;
23428 }
23429 }
23430 }
23431 }
23432
23433 #define BEAMID_COLOR0 (1<<24) //must have rightmost 24 bits empty
23434 14283 static int get_beamid(newcombo const& cmb)
23435 {
23436 //Positive ID is a tile, negative is a color trio. 0 is nil in either case.
23437
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 13049 times.
14283 if(cmb.usrflags&cflag1) //use tile/cset style
23438 1234 return std::max(0,cmb.attributes[0]/10000)|(cmb.attribytes[1]%12)<<24;
23439 else //use 3-color style
23440 {
23441 13049 auto id = -((cmb.attribytes[3]<<16)|(cmb.attribytes[2]<<8)|(cmb.attribytes[1]));
23442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13049 times.
13049 if(!id) //0 would clash with the tile/cset style
23443 id = BEAMID_COLOR0;
23444 13049 return id;
23445 }
23446 14283 }
23447 14283 static bool launch_lightbeam(const rpos_handle_t& rpos_handle, std::map<int32_t, spot_t*>& maps, bool refl, bool block)
23448 {
23449 14283 auto& cmb = rpos_handle.combo();
23450 14283 int32_t id = get_beamid(cmb);
23451 //Get the grid array for this tile/color
23452 spot_t* grid;
23453
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 if(maps[id])
23454 grid = maps[id];
23455 else
23456 {
23457 14283 maps[id] = grid = new spot_t[region_num_rpos];
23458 14283 memset(grid, 0, sizeof(spot_t)*region_num_rpos);
23459 }
23460 14283 byte spotdir = cmb.attribytes[0];
23461
2/2
✓ Branch 0 taken 3861 times.
✓ Branch 1 taken 10422 times.
14283 if(spotdir > 3)
23462 {
23463 10422 grid[(int)rpos_handle.rpos] |= SP_VISITED;
23464
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10422 times.
10422 istrig[(int)rpos_handle.rpos] |= cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23465 10422 }
23466
4/4
✓ Branch 0 taken 10892 times.
✓ Branch 1 taken 3391 times.
✓ Branch 2 taken 8090 times.
✓ Branch 3 taken 2802 times.
14283 if(refl && rpos_handle.rpos == beam_hero_rpos)
23467 {
23468 2802 spotdir = Hero.getDir();
23469 2802 }
23470 14283 handleBeam(grid, 0, spotdir, rpos_handle.rpos, cmb.attribytes[4], block, refl);
23471 14283 return true;
23472 }
23473
23474 static bool launch_fflightbeam(ffcdata const& ffc,
23475 std::map<int32_t, std::map<dword,spot_t>>& ffmaps, bool refl, bool block)
23476 {
23477 newcombo const& cmb = combobuf[ffc.data];
23478 int32_t id = get_beamid(cmb);
23479 //Get the grid array for this tile/color
23480 std::map<dword,spot_t>& grid = ffmaps[id]; // grid of (x<<16)|(y&0xFFFF)
23481 byte spotdir = cmb.attribytes[0];
23482 lightbeam_xy sxy(ffc.x+(ffc.hit_width/2), ffc.y+(ffc.hit_height/2));
23483 if(spotdir > 3 && sxy.valid())
23484 {
23485 grid[sxy.ffpos()] |= SP_VISITED;
23486 int32_t trigflag = cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23487 istrig[(int)sxy.pos()] |= trigflag;
23488 }
23489 auto beamwid = cmb.attribytes[5] < 1 ? 8 : cmb.attribytes[5];
23490 if(refl && beam_hero_rpos != rpos_t::None && sxy.herocollide(beamwid))
23491 {
23492 spotdir = Hero.getDir();
23493 }
23494 switch(spotdir)
23495 {
23496 case up:
23497 sxy.y = zc_min(world_h-1,sxy.y);
23498 break;
23499 case down:
23500 sxy.y = zc_max(0,sxy.y);
23501 break;
23502 case left:
23503 sxy.x = zc_min(world_w-1,sxy.x);
23504 break;
23505 case right:
23506 sxy.x = zc_max(0,sxy.x);
23507 break;
23508 }
23509 handleFFBeam(grid, 0, spotdir, sxy, cmb.attribytes[4], block, refl, beamwid);
23510 return true;
23511 }
23512
23513 14283 static BITMAP* generate_beam_bitmap(int32_t id)
23514 {
23515 14283 BITMAP* cbmp = create_bitmap_ex(8, 16*beamoffs_max, 16);
23516 14283 clear_bitmap(cbmp);
23517
3/4
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 13049 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1234 times.
14283 if(id < 0 || id == BEAMID_COLOR0)
23518 {
23519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13049 times.
13049 int cid = (id == BEAMID_COLOR0) ? 0 : abs(id);
23520 13049 byte c_inner = (cid & 0x0000FF);
23521 13049 byte c_middle = (cid & 0x00FF00)>>8;
23522 13049 byte c_outter = (cid & 0xFF0000)>>16;
23523
2/2
✓ Branch 0 taken 195735 times.
✓ Branch 1 taken 13049 times.
208784 for(size_t q = 1; q < beamoffs_max; ++q)
23524 {
23525 195735 circlefill(cbmp, 16*q+8, 8, 3, c_outter);
23526 195735 circlefill(cbmp, 16*q+7, 8, 3, c_outter);
23527 195735 circlefill(cbmp, 16*q+8, 7, 3, c_outter);
23528 195735 circlefill(cbmp, 16*q+7, 7, 3, c_outter);
23529 195735 circlefill(cbmp, 16*q+8, 8, 1, c_middle);
23530 195735 circlefill(cbmp, 16*q+7, 8, 1, c_middle);
23531 195735 circlefill(cbmp, 16*q+8, 7, 1, c_middle);
23532 195735 circlefill(cbmp, 16*q+7, 7, 1, c_middle);
23533 195735 circlefill(cbmp, 16*q+8, 8, 0, c_inner);
23534 195735 circlefill(cbmp, 16*q+7, 8, 0, c_inner);
23535 195735 circlefill(cbmp, 16*q+8, 7, 0, c_inner);
23536 195735 circlefill(cbmp, 16*q+7, 7, 0, c_inner);
23537 195735 }
23538 //beamoffs_gr
23539 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 7, c_outter);
23540 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 7, c_outter);
23541 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 7, c_outter);
23542 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 7, c_outter);
23543 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 5, c_middle);
23544 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 5, c_middle);
23545 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 5, c_middle);
23546 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 5, c_middle);
23547 13049 circlefill(cbmp, 16*beamoffs_gr+8, 8, 3, c_inner);
23548 13049 circlefill(cbmp, 16*beamoffs_gr+7, 8, 3, c_inner);
23549 13049 circlefill(cbmp, 16*beamoffs_gr+8, 7, 3, c_inner);
23550 13049 circlefill(cbmp, 16*beamoffs_gr+7, 7, 3, c_inner);
23551 //beamoffs_up
23552 13049 rectfill(cbmp, 16*beamoffs_up+4, 0, 16*beamoffs_up+11, 7, c_outter);
23553 13049 rectfill(cbmp, 16*beamoffs_up+6, 0, 16*beamoffs_up+9, 7, c_middle);
23554 13049 rectfill(cbmp, 16*beamoffs_up+7, 0, 16*beamoffs_up+8, 7, c_inner);
23555 //beamoffs_down
23556 13049 rectfill(cbmp, 16*beamoffs_down+4, 8, 16*beamoffs_down+11, 15, c_outter);
23557 13049 rectfill(cbmp, 16*beamoffs_down+6, 8, 16*beamoffs_down+9, 15, c_middle);
23558 13049 rectfill(cbmp, 16*beamoffs_down+7, 8, 16*beamoffs_down+8, 15, c_inner);
23559 //beamoffs_left
23560 13049 rectfill(cbmp, 16*beamoffs_left, 4, 16*beamoffs_left+7, 11, c_outter);
23561 13049 rectfill(cbmp, 16*beamoffs_left, 6, 16*beamoffs_left+7, 9, c_middle);
23562 13049 rectfill(cbmp, 16*beamoffs_left, 7, 16*beamoffs_left+7, 8, c_inner);
23563 //beamoffs_right
23564 13049 rectfill(cbmp, 16*beamoffs_right+8, 4, 16*beamoffs_right+15, 11, c_outter);
23565 13049 rectfill(cbmp, 16*beamoffs_right+8, 6, 16*beamoffs_right+15, 9, c_middle);
23566 13049 rectfill(cbmp, 16*beamoffs_right+8, 7, 16*beamoffs_right+15, 8, c_inner);
23567 //beamoffs_uleft
23568 13049 rectfill(cbmp, 16*beamoffs_uleft+4, 0, 16*beamoffs_uleft+11, 7, c_outter);
23569 13049 rectfill(cbmp, 16*beamoffs_uleft, 4, 16*beamoffs_uleft+7, 11, c_outter);
23570 13049 rectfill(cbmp, 16*beamoffs_uleft, 6, 16*beamoffs_uleft+7, 9, c_middle);
23571 13049 rectfill(cbmp, 16*beamoffs_uleft+6, 0, 16*beamoffs_uleft+9, 7, c_middle);
23572 13049 rectfill(cbmp, 16*beamoffs_uleft+7, 0, 16*beamoffs_uleft+8, 7, c_inner);
23573 13049 rectfill(cbmp, 16*beamoffs_uleft, 7, 16*beamoffs_uleft+7, 8, c_inner);
23574 //beamoffs_uright
23575 13049 rectfill(cbmp, 16*beamoffs_uright+4, 0, 16*beamoffs_uright+11, 7, c_outter);
23576 13049 rectfill(cbmp, 16*beamoffs_uright+8, 4, 16*beamoffs_uright+15, 11, c_outter);
23577 13049 rectfill(cbmp, 16*beamoffs_uright+8, 6, 16*beamoffs_uright+15, 9, c_middle);
23578 13049 rectfill(cbmp, 16*beamoffs_uright+6, 0, 16*beamoffs_uright+9, 7, c_middle);
23579 13049 rectfill(cbmp, 16*beamoffs_uright+7, 0, 16*beamoffs_uright+8, 7, c_inner);
23580 13049 rectfill(cbmp, 16*beamoffs_uright+8, 7, 16*beamoffs_uright+15, 8, c_inner);
23581 //beamoffs_dleft
23582 13049 rectfill(cbmp, 16*beamoffs_dleft+4, 8, 16*beamoffs_dleft+11, 15, c_outter);
23583 13049 rectfill(cbmp, 16*beamoffs_dleft, 4, 16*beamoffs_dleft+7, 11, c_outter);
23584 13049 rectfill(cbmp, 16*beamoffs_dleft, 6, 16*beamoffs_dleft+7, 9, c_middle);
23585 13049 rectfill(cbmp, 16*beamoffs_dleft+6, 8, 16*beamoffs_dleft+9, 15, c_middle);
23586 13049 rectfill(cbmp, 16*beamoffs_dleft+7, 8, 16*beamoffs_dleft+8, 15, c_inner);
23587 13049 rectfill(cbmp, 16*beamoffs_dleft, 7, 16*beamoffs_dleft+7, 8, c_inner);
23588 //beamoffs_dright
23589 13049 rectfill(cbmp, 16*beamoffs_dright+4, 8, 16*beamoffs_dright+11, 15, c_outter);
23590 13049 rectfill(cbmp, 16*beamoffs_dright+8, 4, 16*beamoffs_dright+15, 11, c_outter);
23591 13049 rectfill(cbmp, 16*beamoffs_dright+8, 6, 16*beamoffs_dright+15, 9, c_middle);
23592 13049 rectfill(cbmp, 16*beamoffs_dright+6, 8, 16*beamoffs_dright+9, 15, c_middle);
23593 13049 rectfill(cbmp, 16*beamoffs_dright+7, 8, 16*beamoffs_dright+8, 15, c_inner);
23594 13049 rectfill(cbmp, 16*beamoffs_dright+8, 7, 16*beamoffs_dright+15, 8, c_inner);
23595 //beamoffs_vert
23596 13049 rectfill(cbmp, 16*beamoffs_vert+4, 0, 16*beamoffs_vert+11, 15, c_outter);
23597 13049 rectfill(cbmp, 16*beamoffs_vert+6, 0, 16*beamoffs_vert+9, 15, c_middle);
23598 13049 rectfill(cbmp, 16*beamoffs_vert+7, 0, 16*beamoffs_vert+8, 15, c_inner);
23599 //beamoffs_horz
23600 13049 rectfill(cbmp, 16*beamoffs_horz, 4, 16*beamoffs_horz+15, 11, c_outter);
23601 13049 rectfill(cbmp, 16*beamoffs_horz, 6, 16*beamoffs_horz+15, 9, c_middle);
23602 13049 rectfill(cbmp, 16*beamoffs_horz, 7, 16*beamoffs_horz+15, 8, c_inner);
23603 //beamoffs_notup
23604 13049 rectfill(cbmp, 16*beamoffs_notup, 4, 16*beamoffs_notup+15, 11, c_outter);
23605 13049 rectfill(cbmp, 16*beamoffs_notup+4, 8, 16*beamoffs_notup+11, 15, c_outter);
23606 13049 rectfill(cbmp, 16*beamoffs_notup+6, 8, 16*beamoffs_notup+9, 15, c_middle);
23607 13049 rectfill(cbmp, 16*beamoffs_notup, 6, 16*beamoffs_notup+15, 9, c_middle);
23608 13049 rectfill(cbmp, 16*beamoffs_notup, 7, 16*beamoffs_notup+15, 8, c_inner);
23609 13049 rectfill(cbmp, 16*beamoffs_notup+7, 8, 16*beamoffs_notup+8, 15, c_inner);
23610 //beamoffs_notdown
23611 13049 rectfill(cbmp, 16*beamoffs_notdown, 4, 16*beamoffs_notdown+15, 11, c_outter);
23612 13049 rectfill(cbmp, 16*beamoffs_notdown+4, 0, 16*beamoffs_notdown+11, 7, c_outter);
23613 13049 rectfill(cbmp, 16*beamoffs_notdown+6, 0, 16*beamoffs_notdown+9, 7, c_middle);
23614 13049 rectfill(cbmp, 16*beamoffs_notdown, 6, 16*beamoffs_notdown+15, 9, c_middle);
23615 13049 rectfill(cbmp, 16*beamoffs_notdown, 7, 16*beamoffs_notdown+15, 8, c_inner);
23616 13049 rectfill(cbmp, 16*beamoffs_notdown+7, 0, 16*beamoffs_notdown+8, 7, c_inner);
23617 //beamoffs_notleft
23618 13049 rectfill(cbmp, 16*beamoffs_notleft+4, 0, 16*beamoffs_notleft+11, 15, c_outter);
23619 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 4, 16*beamoffs_notleft+15, 11, c_outter);
23620 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 6, 16*beamoffs_notleft+15, 9, c_middle);
23621 13049 rectfill(cbmp, 16*beamoffs_notleft+6, 0, 16*beamoffs_notleft+9, 15, c_middle);
23622 13049 rectfill(cbmp, 16*beamoffs_notleft+7, 0, 16*beamoffs_notleft+8, 15, c_inner);
23623 13049 rectfill(cbmp, 16*beamoffs_notleft+8, 7, 16*beamoffs_notleft+15, 8, c_inner);
23624 //beamoffs_notright
23625 13049 rectfill(cbmp, 16*beamoffs_notright+4, 0, 16*beamoffs_notright+11, 15, c_outter);
23626 13049 rectfill(cbmp, 16*beamoffs_notright, 4, 16*beamoffs_notright+7, 11, c_outter);
23627 13049 rectfill(cbmp, 16*beamoffs_notright, 6, 16*beamoffs_notright+7, 9, c_middle);
23628 13049 rectfill(cbmp, 16*beamoffs_notright+6, 0, 16*beamoffs_notright+9, 15, c_middle);
23629 13049 rectfill(cbmp, 16*beamoffs_notright+7, 0, 16*beamoffs_notright+8, 15, c_inner);
23630 13049 rectfill(cbmp, 16*beamoffs_notright, 7, 16*beamoffs_notright+7, 8, c_inner);
23631 //beamoffs_all
23632 13049 rectfill(cbmp, 16*beamoffs_all+4, 0, 16*beamoffs_all+11, 15, c_outter);
23633 13049 rectfill(cbmp, 16*beamoffs_all, 4, 16*beamoffs_all+15, 11, c_outter);
23634 13049 rectfill(cbmp, 16*beamoffs_all, 6, 16*beamoffs_all+15, 9, c_middle);
23635 13049 rectfill(cbmp, 16*beamoffs_all+6, 0, 16*beamoffs_all+9, 15, c_middle);
23636 13049 rectfill(cbmp, 16*beamoffs_all+7, 0, 16*beamoffs_all+8, 15, c_inner);
23637 13049 rectfill(cbmp, 16*beamoffs_all, 7, 16*beamoffs_all+15, 8, c_inner);
23638 13049 }
23639 else
23640 {
23641 1234 int32_t tile = (id&0xFFFFFF);
23642 1234 int32_t cs = (id>>24);
23643
2/2
✓ Branch 0 taken 19744 times.
✓ Branch 1 taken 1234 times.
20978 for(size_t q = 0; q < beamoffs_max; ++q)
23644 19744 puttile16(cbmp, tile+q, q*16, 0, cs, 0);
23645 }
23646 14283 return cbmp;
23647 }
23648
23649 2499525 static int32_t get_beamoffs(spot_t val)
23650 {
23651
12/17
✗ Branch 0 not taken.
✓ Branch 1 taken 2430030 times.
✓ Branch 2 taken 1469 times.
✓ Branch 3 taken 1188 times.
✓ Branch 4 taken 1795 times.
✓ Branch 5 taken 1768 times.
✓ Branch 6 taken 14821 times.
✓ Branch 7 taken 31678 times.
✓ Branch 8 taken 4877 times.
✓ Branch 9 taken 3412 times.
✓ Branch 10 taken 4161 times.
✓ Branch 11 taken 3791 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✓ Branch 16 taken 535 times.
2499525 switch((val&SP_MASK)>>1)
23652 {
23653 2430030 case 0: default:
23654
2/2
✓ Branch 0 taken 7620 times.
✓ Branch 1 taken 2422410 times.
2430030 if(val)
23655 7620 return beamoffs_gr;
23656 2422410 return -1;
23657 case 0b0001:
23658 1469 return beamoffs_up;
23659 case 0b0010:
23660 1188 return beamoffs_down;
23661 case 0b0100:
23662 1795 return beamoffs_left;
23663 case 0b1000:
23664 1768 return beamoffs_right;
23665 case 0b0011:
23666 14821 return beamoffs_vert;
23667 case 0b1100:
23668 31678 return beamoffs_horz;
23669 case 0b0101:
23670 4877 return beamoffs_uleft;
23671 case 0b1001:
23672 3412 return beamoffs_uright;
23673 case 0b0110:
23674 4161 return beamoffs_dleft;
23675 case 0b1010:
23676 3791 return beamoffs_dright;
23677 case 0b1110:
23678 return beamoffs_notup;
23679 case 0b1101:
23680 return beamoffs_notdown;
23681 case 0b1011:
23682 return beamoffs_notleft;
23683 case 0b0111:
23684 return beamoffs_notright;
23685 case 0b1111:
23686 535 return beamoffs_all;
23687 }
23688 return -1;
23689 2499525 }
23690
23691 14307772 void HeroClass::handleSpotlights()
23692 {
23693 static bool had_spotlight = true;
23694
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 14293489 times.
14307772 if (cpos_exists_spotlight())
23695 {
23696 14283 istrig.clear();
23697 14283 customTypeMap.clear();
23698 14283 typeMap.clear();
23699
23700 14283 typeMap.resize(region_num_rpos);
23701 14283 customTypeMap.resize(region_num_rpos);
23702 14283 istrig.resize(region_num_rpos);
23703
23704 //Store each different tile/color as grids
23705 14283 std::map<int32_t, spot_t*> maps;
23706 14283 std::map<int32_t, std::map<dword, spot_t>> ffmaps;
23707
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 int32_t shieldid = getCurrentShield(false);
23708
2/8
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14283 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14283 if((itemsbuf[shieldid].flags & item_flag9) && !usingActiveShield(shieldid))
23709 shieldid = -1;
23710
2/2
✓ Branch 0 taken 3391 times.
✓ Branch 1 taken 10892 times.
14283 bool refl = shieldid > -1 && (itemsbuf[shieldid].misc2 & sh_lightbeam);
23711
3/4
✓ Branch 0 taken 3391 times.
✓ Branch 1 taken 10892 times.
✓ Branch 2 taken 3391 times.
✗ Branch 3 not taken.
14283 bool block = !refl && shieldid > -1 && (itemsbuf[shieldid].misc1 & sh_lightbeam);
23712
3/6
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14283 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14283 times.
✗ Branch 5 not taken.
14283 beam_hero_rpos = COMBOPOS_REGION_B(x.getInt()+8, y.getInt()+8);
23713
23714
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 clear_bitmap(lightbeam_bmp);
23715
23716 14283 bool found_any_light = false;
23717
23718
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
28566 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
23719 14283 bool pos_has_seen_cmb[176] = {0};
23720
23721
2/2
✓ Branch 0 taken 99981 times.
✓ Branch 1 taken 14283 times.
114264 for(int32_t lyr = 6; lyr >= 0; --lyr)
23722 {
23723 99981 mapscr* layer_scr = get_scr_layer(scr->screen, lyr);
23724
2/2
✓ Branch 0 taken 17596656 times.
✓ Branch 1 taken 99981 times.
17696637 for(size_t pos = 0; pos < 176; ++pos)
23725 {
23726
2/2
✓ Branch 0 taken 3723 times.
✓ Branch 1 taken 17592933 times.
17596656 if (pos_has_seen_cmb[pos])
23727 3723 continue;
23728
23729 17592933 rpos_t rpos = POS_TO_RPOS(pos, region_scr_x, region_scr_y);
23730 17592933 auto& cmb = combobuf[layer_scr->data[pos]];
23731 17592933 bool found_combo = false;
23732
5/6
✓ Branch 0 taken 162275 times.
✓ Branch 1 taken 13142 times.
✓ Branch 2 taken 17399531 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3702 times.
✓ Branch 5 taken 14283 times.
17592933 switch(cmb.type)
23733 {
23734 case cMIRROR: case cMIRRORSLASH: case cMIRRORBACKSLASH:
23735 case cMAGICPRISM: case cMAGICPRISM4:
23736
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 162275 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
162275 if(!cmb.attributes[0] || (cmb.attributes[0] & sh_lightbeam))
23737 {
23738 162275 typeMap[(int)rpos] = cmb.type;
23739 162275 found_combo = true;
23740 162275 }
23741 162275 break;
23742 case cBLOCKALL: case cLIGHTTARGET:
23743 13142 typeMap[(int)rpos] = cmb.type;
23744 13142 found_combo = true;
23745 13142 break;
23746 case cMIRRORNEW:
23747 if(!cmb.attributes[0] || (cmb.attributes[0] & sh_lightbeam))
23748 {
23749 typeMap[(int)rpos] = cMIRRORNEW;
23750 customTypeMap[(int)rpos] = layer_scr->data[pos];
23751 found_combo = true;
23752 }
23753 break;
23754 case cGLASS:
23755 3702 found_combo = true;
23756 // Already been initialized to zero.
23757 3702 break;
23758 case cSPOTLIGHT:
23759 14283 found_any_light = true;
23760 14283 break;
23761 }
23762
2/2
✓ Branch 0 taken 179119 times.
✓ Branch 1 taken 17413814 times.
17592933 if(found_combo)
23763 179119 pos_has_seen_cmb[pos] = true;
23764
4/4
✓ Branch 0 taken 7358582 times.
✓ Branch 1 taken 10055232 times.
✓ Branch 2 taken 6017045 times.
✓ Branch 3 taken 1341537 times.
17413814 else if(lyr < 3 && (cmb.walk & 0xF))
23765 1341537 typeMap[(int)rpos] = SPTYPE_SOLID;
23766 17592933 }
23767 99981 }
23768
23769
2/2
✓ Branch 0 taken 2513808 times.
✓ Branch 1 taken 14283 times.
2528091 for (int pos = 0; pos < 176; pos++)
23770 {
23771 2513808 rpos_t rpos = POS_TO_RPOS(pos, region_scr_x, region_scr_y);
23772
4/4
✓ Branch 0 taken 2296624 times.
✓ Branch 1 taken 217184 times.
✓ Branch 2 taken 1421859 times.
✓ Branch 3 taken 874765 times.
2513808 if (!get_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ) && !typeMap[(int)rpos])
23773 {
23774 1749530 auto [x, y] = COMBOXY_REGION(rpos);
23775
2/4
✓ Branch 0 taken 874765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 874765 times.
✗ Branch 3 not taken.
1749530 if (collide_object(x, y, 16, 16, this))
23776 typeMap[(int)rpos] = SPTYPE_SOLID;
23777 874765 }
23778 2513808 }
23779 14283 });
23780
23781 // The world is dark and full of terrors.
23782
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 if (!found_any_light) return;
23783
23784
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 14031 times.
14283 switch (typeMap[(int)beam_hero_rpos])
23785 {
23786 case SPTYPE_SOLID: case cBLOCKALL:
23787 252 beam_hero_rpos = rpos_t::None; //Blocked from hitting player
23788 252 }
23789
23790
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
5721435 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
23791
2/2
✓ Branch 0 taken 5692869 times.
✓ Branch 1 taken 14283 times.
5707152 if (rpos_handle.ctype() == cSPOTLIGHT)
23792 14283 launch_lightbeam(rpos_handle, maps, refl, block);
23793 5707152 });
23794
23795
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
17985 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
23796 3702 ffcdata& ffc = *ffc_handle.ffc;
23797
1/2
✓ Branch 0 taken 3702 times.
✗ Branch 1 not taken.
3702 if (ffc.flags & (ffc_changer|ffc_ethereal))
23798 return;
23799
23800 3702 newcombo const& cmb = combobuf[ffc.data];
23801
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3702 if (ffc_handle.ctype() == cSPOTLIGHT && (cmb.usrflags&cflag2))
23802 launch_fflightbeam(ffc,ffmaps,refl,block);
23803 3702 });
23804
23805
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 lightbeam_present = !maps.empty() || !ffmaps.empty();
23806
23807 //Draw visuals
23808
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 14283 times.
28566 for(auto it = maps.begin(); it != maps.end();)
23809 {
23810 14283 int32_t id = it->first;
23811 14283 spot_t* grid = it->second;
23812
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 BITMAP* cbmp = generate_beam_bitmap(id);
23813
2/2
✓ Branch 0 taken 14283 times.
✓ Branch 1 taken 2499525 times.
2513808 for (rpos_t rpos = (rpos_t)0; rpos < region_max_rpos; rpos = (rpos_t)((int)rpos + 1))
23814 {
23815
1/2
✓ Branch 0 taken 2499525 times.
✗ Branch 1 not taken.
2499525 int32_t offs = get_beamoffs(grid[(int)rpos]);
23816
2/2
✓ Branch 0 taken 77115 times.
✓ Branch 1 taken 2422410 times.
2499525 if(offs > -1)
23817 {
23818
1/2
✓ Branch 0 taken 77115 times.
✗ Branch 1 not taken.
77115 auto [x, y] = COMBOXY_REGION(rpos);
23819
3/6
✓ Branch 0 taken 77115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 77115 times.
✗ Branch 5 not taken.
231345 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, x-viewport.x, y-viewport.y, 16, 16);
23820 77115 }
23821 2499525 }
23822
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 destroy_bitmap(cbmp);
23823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
14283 delete[] it->second;
23824
1/2
✓ Branch 0 taken 14283 times.
✗ Branch 1 not taken.
14283 it = maps.erase(it);
23825 }
23826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14283 times.
14283 for(auto it = ffmaps.begin(); it != ffmaps.end();)
23827 {
23828 int32_t id = it->first;
23829 std::map<dword,spot_t> const& grid = it->second;
23830 BITMAP* cbmp = generate_beam_bitmap(id);
23831 for(auto it2 = grid.begin(); it2 != grid.end(); ++it2)
23832 {
23833 lightbeam_xy ffxy(it2->first);
23834 int32_t offs = get_beamoffs(it2->second);
23835 if(offs > -1)
23836 masked_blit(cbmp, lightbeam_bmp, offs*16, 0, ffxy.x-8-viewport.x, ffxy.y-8-viewport.y, 16, 16);
23837 }
23838 destroy_bitmap(cbmp);
23839 it = ffmaps.erase(it);
23840 }
23841
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 14283 times.
14283 }
23842 else
23843 {
23844
2/2
✓ Branch 0 taken 14293170 times.
✓ Branch 1 taken 319 times.
14293489 if(had_spotlight)
23845 {
23846 319 istrig.clear();
23847 319 istrig.resize(region_num_rpos);
23848 319 clear_bitmap(lightbeam_bmp);
23849 319 }
23850 14293489 lightbeam_present = false;
23851 }
23852
23853 14307772 had_spotlight = lightbeam_present;
23854
23855 //Check triggers
23856 14307772 auto& combo_cache = combo_caches::spotlight;
23857 14307772 std::set<int> screens_triggered;
23858 14307772 bool istrigged = true;
23859
1/2
✓ Branch 0 taken 14307772 times.
✗ Branch 1 not taken.
5417105788 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
23860 5402798016 auto& mini_cmb = combo_cache.minis[rpos_handle.data()];
23861
2/2
✓ Branch 0 taken 13121 times.
✓ Branch 1 taken 5402784895 times.
5402798016 if (mini_cmb.target)
23862 {
23863 13121 auto& cmb = rpos_handle.combo();
23864 13121 bool alltrig = getmapflag(rpos_handle.scr, mLIGHTBEAM);
23865
2/2
✓ Branch 0 taken 11887 times.
✓ Branch 1 taken 1234 times.
13121 int32_t trigflag = cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23866 13121 screens_triggered.insert(rpos_handle.screen);
23867 13121 bool trigged = (istrig[(int)rpos_handle.rpos]&trigflag);
23868
1/2
✓ Branch 0 taken 13121 times.
✗ Branch 1 not taken.
13121 if(cmb.usrflags&cflag2) //Invert
23869 trigged = !trigged;
23870
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 12872 times.
13121 if(cmb.usrflags&cflag1) //Solved Version
23871 {
23872
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
23873 {
23874 rpos_handle.decrement_data();
23875 istrigged = false;
23876 }
23877 249 }
23878 else //Unsolved version
23879 {
23880
3/4
✓ Branch 0 taken 12872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 12868 times.
12872 if(alltrig || trigged) //Light
23881 4 rpos_handle.increment_data();
23882 12868 else istrigged = false;
23883 }
23884 13121 }
23885
2/2
✓ Branch 0 taken 5402781193 times.
✓ Branch 1 taken 3702 times.
5402784895 else if (mini_cmb.trigger)
23886 {
23887
1/2
✓ Branch 0 taken 3702 times.
✗ Branch 1 not taken.
7404 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
23888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3702 times.
3702 int32_t trigflag = trig.triglbeam ? (1 << (trig.triglbeam-1)) : ~0;
23889 3702 bool trigged = (istrig[(int)rpos_handle.rpos]&trigflag);
23890 3702 return trig.trigger_flags.get(trigged ? TRIGFLAG_LIGHTON : TRIGFLAG_LIGHTOFF);
23891 });
23892 3702 }
23893 5402798016 });
23894
23895
1/2
✓ Branch 0 taken 14307772 times.
✗ Branch 1 not taken.
453813193 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
23896 439505421 ffcdata& ffc = *ffc_handle.ffc;
23897
2/2
✓ Branch 0 taken 438911956 times.
✓ Branch 1 taken 593465 times.
439505421 rpos_t rpos = get_qr(qr_BROKEN_LIGHTBEAM_HITBOX)
23898 438911956 ? COMBOPOS_REGION_B(ffc.x+8, ffc.y+8)
23899 593465 : COMBOPOS_REGION_B(ffc.x+(ffc.hit_width/2), ffc.y+(ffc.hit_height/2));
23900
2/2
✓ Branch 0 taken 309006 times.
✓ Branch 1 taken 439196415 times.
439505421 if (rpos == rpos_t::None)
23901 309006 return;
23902
23903 439196415 auto& mini_cmb = combo_cache.minis[ffc_handle.data()];
23904
2/2
✓ Branch 0 taken 1234 times.
✓ Branch 1 taken 439195181 times.
439196415 if (mini_cmb.target)
23905 {
23906 1234 auto& cmb = ffc_handle.combo();
23907 1234 bool alltrig = getmapflag(ffc_handle.scr, mLIGHTBEAM);
23908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1234 times.
1234 int32_t trigflag = cmb.attribytes[4] ? (1 << (cmb.attribytes[4]-1)) : ~0;
23909 1234 screens_triggered.insert(ffc_handle.screen);
23910 1234 bool trigged = (istrig[(int)rpos]&trigflag);
23911
1/2
✓ Branch 0 taken 1234 times.
✗ Branch 1 not taken.
1234 if(cmb.usrflags&cflag2) //Invert
23912 trigged = !trigged;
23913
2/2
✓ Branch 0 taken 249 times.
✓ Branch 1 taken 985 times.
1234 if(cmb.usrflags&cflag1) //Solved Version
23914 {
23915
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 249 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
249 if(!(alltrig || trigged)) //Revert
23916 {
23917 zc_ffc_modify(ffc, -1);
23918 istrigged = false;
23919 }
23920 249 }
23921 else //Unsolved version
23922 {
23923
3/4
✓ Branch 0 taken 985 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 984 times.
985 if(alltrig || trigged) //Light
23924 1 zc_ffc_modify(ffc, 1);
23925 984 else istrigged = false;
23926 }
23927 1234 }
23928 else //if (mini_cmb.trigger)
23929 {
23930
1/2
✓ Branch 0 taken 439195181 times.
✗ Branch 1 not taken.
439319882 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
23931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124701 times.
124701 int32_t trigflag = trig.triglbeam ? (1 << (trig.triglbeam-1)) : ~0;
23932 124701 bool trigged = (istrig[(int)rpos]&trigflag);
23933 124701 return trig.trigger_flags.get(trigged ? TRIGFLAG_LIGHTON : TRIGFLAG_LIGHTOFF);
23934 });
23935 }
23936 439505421 });
23937
23938 // Trigger secrets for every screen that has a light trigger.
23939
4/4
✓ Branch 0 taken 14294904 times.
✓ Branch 1 taken 12868 times.
✓ Branch 2 taken 14294651 times.
✓ Branch 3 taken 253 times.
14307772 if (istrigged && !screens_triggered.empty())
23940 {
23941
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 253 times.
506 for (int screen : screens_triggered)
23942 {
23943
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 mapscr* scr = get_scr(screen);
23944
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 bool alltrig = getmapflag(scr, mLIGHTBEAM);
23945
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 249 times.
253 if (alltrig)
23946 249 continue;
23947
23948
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 trigger_secrets_for_screen(TriggerSource::LightTrigger, screen, false);
23949
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 sfx(scr->secretsfx);
23950
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!(scr->flags5&fTEMPSECRETS))
23951 {
23952
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setmapflag(scr, mSECRET);
23953
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setmapflag(scr, mLIGHTBEAM);
23954 4 }
23955 }
23956 253 }
23957 14307772 }
23958
23959 14283256 void HeroClass::checktouchblk()
23960 {
23961
2/2
✓ Branch 0 taken 14953 times.
✓ Branch 1 taken 14268303 times.
14283256 if(toogam) return;
23962
23963
2/2
✓ Branch 0 taken 960681 times.
✓ Branch 1 taken 13307622 times.
14268303 if(!pushing)
23964 13307622 return;
23965
23966 960681 int32_t tdir = dir; //Bad hack #2. _L_, your welcome to fix this properly. ;)
23967
23968
4/4
✓ Branch 0 taken 951905 times.
✓ Branch 1 taken 8776 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 951809 times.
960681 if(charging > 0 || spins > 0) //if not I probably will at some point...
23969 {
23970
4/4
✓ Branch 0 taken 4072 times.
✓ Branch 1 taken 4800 times.
✓ Branch 2 taken 2940 times.
✓ Branch 3 taken 1132 times.
8872 if (getInput(btnUp, INPUT_HERO_ACTION) && getInput(btnLeft, INPUT_HERO_ACTION)) tdir = (charging % 2) * 2;
23971
4/4
✓ Branch 0 taken 2940 times.
✓ Branch 1 taken 4800 times.
✓ Branch 2 taken 1410 times.
✓ Branch 3 taken 1530 times.
7740 else if (getInput(btnUp, INPUT_HERO_ACTION) && getInput(btnRight, INPUT_HERO_ACTION)) tdir = (charging % 2) * 3;
23972
4/4
✓ Branch 0 taken 2544 times.
✓ Branch 1 taken 3666 times.
✓ Branch 2 taken 1681 times.
✓ Branch 3 taken 863 times.
6210 else if (getInput(btnDown, INPUT_HERO_ACTION) && getInput(btnLeft, INPUT_HERO_ACTION)) tdir = 1 + (charging % 2) * 1;
23973
4/4
✓ Branch 0 taken 1681 times.
✓ Branch 1 taken 3666 times.
✓ Branch 2 taken 869 times.
✓ Branch 3 taken 812 times.
5347 else if (getInput(btnDown, INPUT_HERO_ACTION) && getInput(btnRight, INPUT_HERO_ACTION)) tdir = 1 + (charging % 2) * 2;
23974 else
23975 {
23976
2/2
✓ Branch 0 taken 1410 times.
✓ Branch 1 taken 3125 times.
4535 if (getInput(btnUp, INPUT_HERO_ACTION)) tdir = 0;
23977
2/2
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 2261 times.
3125 else if (getInput(btnDown, INPUT_HERO_ACTION)) tdir = 1;
23978
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 1382 times.
2261 else if (getInput(btnLeft, INPUT_HERO_ACTION)) tdir = 2;
23979
1/2
✓ Branch 0 taken 1382 times.
✗ Branch 1 not taken.
1382 else if (getInput(btnRight, INPUT_HERO_ACTION)) tdir = 3;
23980 }
23981 8872 }
23982
23983 960681 int32_t tx=0,ty=-1;
23984
23985
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 239559 times.
✓ Branch 2 taken 215738 times.
✓ Branch 3 taken 235775 times.
✓ Branch 4 taken 269609 times.
960681 switch(tdir)
23986 {
23987 case up:
23988
2/2
✓ Branch 0 taken 221 times.
✓ Branch 1 taken 239338 times.
239559 if(touchcombo(x,y+(bigHitbox?0:7)))
23989 {
23990 221 tx=x;
23991 221 ty=y+(bigHitbox?0:7);
23992 221 }
23993
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 239313 times.
239338 else if(touchcombo(x+8,y+(bigHitbox?0:7)))
23994 {
23995 25 tx=x+8;
23996 25 ty=y+(bigHitbox?0:7);
23997 25 }
23998
23999 239559 break;
24000
24001 case down:
24002
2/2
✓ Branch 0 taken 1673 times.
✓ Branch 1 taken 214065 times.
215738 if(touchcombo(x,y+16))
24003 {
24004 1673 tx=x;
24005 1673 ty=y+16;
24006 1673 }
24007
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 213801 times.
214065 else if(touchcombo(x+8,y+16))
24008 {
24009 264 tx=x+8;
24010 264 ty=y+16;
24011 264 }
24012
24013 215738 break;
24014
24015 case left:
24016
2/2
✓ Branch 0 taken 234934 times.
✓ Branch 1 taken 841 times.
235775 if(touchcombo(x-1,y+15))
24017 {
24018 841 tx=x-1;
24019 841 ty=y+15;
24020 841 }
24021
24022 235775 break;
24023
24024 case right:
24025
2/2
✓ Branch 0 taken 268427 times.
✓ Branch 1 taken 1182 times.
269609 if(touchcombo(x+16,y+15))
24026 {
24027 1182 tx=x+16;
24028 1182 ty=y+15;
24029 1182 }
24030
24031 269609 break;
24032 }
24033
24034
2/2
✓ Branch 0 taken 956475 times.
✓ Branch 1 taken 4206 times.
960681 if(ty>=0)
24035 {
24036
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4206 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4206 if (getAction() != hopping || isSideViewHero())
24037 {
24038 4206 trigger_armos_grave(get_rpos_handle_for_world_xy(tx, ty, 0), dir);
24039 4206 }
24040 4206 }
24041 14283256 }
24042
24043 int32_t HeroClass::nextcombo(int32_t cx, int32_t cy, int32_t cdir)
24044 {
24045 switch(cdir)
24046 {
24047 case up:
24048 cy-=16;
24049 break;
24050
24051 case down:
24052 cy+=16;
24053 break;
24054
24055 case left:
24056 cx-=16;
24057 break;
24058
24059 case right:
24060 cx+=16;
24061 break;
24062 }
24063
24064 // off the screen
24065 if(cx<0 || cy<0 || cx>=world_w || cy>=world_h)
24066 {
24067 auto [map, screen] = nextscr2(cdir);
24068 if (map == -1)
24069 return 0;
24070
24071 switch(cdir)
24072 {
24073 case up:
24074 cy=160;
24075 break;
24076
24077 case down:
24078 cy=0;
24079 break;
24080
24081 case left:
24082 cx=240;
24083 break;
24084
24085 case right:
24086 cx=0;
24087 break;
24088 }
24089
24090 int32_t cmb = COMBOPOS(cx%256, cy%176);
24091 return get_canonical_scr(map, screen)->data[cmb];
24092 }
24093
24094 return MAPCOMBO(cx,cy);
24095 }
24096
24097 15867 int32_t HeroClass::nextflag(int32_t cx, int32_t cy, int32_t cdir, bool comboflag)
24098 {
24099
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3203 times.
✓ Branch 2 taken 3545 times.
✓ Branch 3 taken 3978 times.
✓ Branch 4 taken 5141 times.
15867 switch(cdir)
24100 {
24101 case up:
24102 3203 cy-=16;
24103 3203 break;
24104
24105 case down:
24106 3545 cy+=16;
24107 3545 break;
24108
24109 case left:
24110 3978 cx-=16;
24111 3978 break;
24112
24113 case right:
24114 5141 cx+=16;
24115 5141 break;
24116 }
24117
24118 // off the screen
24119
8/8
✓ Branch 0 taken 15766 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 15621 times.
✓ Branch 3 taken 145 times.
✓ Branch 4 taken 15447 times.
✓ Branch 5 taken 174 times.
✓ Branch 6 taken 192 times.
✓ Branch 7 taken 15255 times.
15867 if(cx<0 || cy<0 || cx>=world_w || cy>=world_h)
24120 {
24121 1828 auto [map, screen] = nextscr2(cdir);
24122
2/2
✓ Branch 0 taken 608 times.
✓ Branch 1 taken 4 times.
612 if (map == -1)
24123 4 return 0;
24124
24125
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 101 times.
✓ Branch 4 taken 174 times.
608 switch(cdir)
24126 {
24127 case up:
24128 143 cy=160;
24129 143 break;
24130
24131 case down:
24132 190 cy=0;
24133 190 break;
24134
24135 case left:
24136 101 cx=240;
24137 101 break;
24138
24139 case right:
24140 174 cx=0;
24141 174 break;
24142 }
24143
24144 608 int32_t pos = COMBOPOS(cx%256, cy%176);
24145 1216 const mapscr* scr = get_canonical_scr(map, screen);
24146
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 523 times.
608 if (!comboflag)
24147 {
24148 523 return scr->sflag[pos];
24149 }
24150 else
24151 {
24152 85 return combo_caches::flag.minis[scr->data[pos]].flag;
24153 }
24154 }
24155
24156
2/2
✓ Branch 0 taken 3952 times.
✓ Branch 1 taken 11303 times.
15255 if(comboflag)
24157 {
24158 3952 return MAPCOMBOFLAG(cx,cy);
24159 }
24160
24161 11303 return MAPFLAG(cx,cy);
24162 15867 }
24163
24164 14283256 void HeroClass::checkspecial()
24165 {
24166 14283256 checktouchblk();
24167
24168 28918934 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
24169 14635678 int screen = scr->screen;
24170 14635678 auto& state = get_screen_state(screen);
24171 14635678 bool hasmainguy = hasMainGuy(screen);
24172
4/4
✓ Branch 0 taken 14208476 times.
✓ Branch 1 taken 427202 times.
✓ Branch 2 taken 8558066 times.
✓ Branch 3 taken 5650410 times.
14635678 if (!state.loaded_enemies || hasmainguy)
24173 {
24174 8985268 state.did_enemy_secret = false;
24175 8985268 }
24176 else
24177 {
24178 // Enemies have been defeated.
24179
24180 // generic 'Enemies->' trigger
24181 2102219351 for_every_combo_in_screen(create_screen_handles(scr), [&](const auto& handle) {
24182
2/4
✓ Branch 0 taken 2094958272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1610669 times.
✗ Branch 3 not taken.
2183321154 trig_each_combo_trigger(handle, [&](combo_trigger const& trig){
24183 86752213 return trig.trigger_flags.get(TRIGFLAG_ENEMIESKILLED);
24184 });
24185 2096568941 });
24186
24187
1/2
✓ Branch 0 taken 5650410 times.
✗ Branch 1 not taken.
5650410 if (scr->flags9 & fENEMY_WAVES)
24188 {
24189 hasmainguy = hasMainGuy(screen); //possibly un-beat the enemies (another 'wave'?)
24190 }
24191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5650410 times.
5650410 if(!hasmainguy)
24192 {
24193 // item
24194
5/6
✓ Branch 0 taken 5650402 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 5650402 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 754 times.
✓ Branch 5 taken 5649648 times.
5650410 if (state.item_state == ScreenItemState::MustGiveToEnemy || state.item_state == ScreenItemState::CarriedByEnemy || state.item_state == ScreenItemState::WhenKillEnemies)
24195 {
24196 762 int32_t Item=scr->item;
24197
24198
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 762 times.
762 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
24199 {
24200
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 754 times.
762 if (state.item_state == ScreenItemState::WhenKillEnemies)
24201 754 sfx(WAV_CLEARED);
24202
24203 762 zfix x = region_scr_x*256 + scr->itemx;
24204
3/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 691 times.
✓ Branch 2 taken 71 times.
✗ Branch 3 not taken.
762 zfix y = region_scr_y*176 + ((scr->flags7&fITEMFALLS && isSideViewHero()) ? -170 : scr->itemy+1);
24205
9/16
✓ Branch 0 taken 762 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 762 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 71 times.
✓ Branch 5 taken 691 times.
✓ Branch 6 taken 71 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 71 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 71 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 691 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 762 times.
✗ Branch 15 not taken.
1524 add_item_for_screen(screen, new item(x, y, (scr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
24206
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 761 times.
762 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].type==itype_triforcepiece ||
24207 762 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
24208 762 }
24209
24210 762 state.item_state = ScreenItemState::None;
24211 762 }
24212
2/2
✓ Branch 0 taken 114607 times.
✓ Branch 1 taken 5535803 times.
5650410 if(!getmapflag(scr, mTMPNORET))
24213 {
24214 // if room has traps, guys don't come back
24215
2/2
✓ Branch 0 taken 5535706 times.
✓ Branch 1 taken 2834291016 times.
2839826722 for (int32_t i=0; i<eMAXGUYS; i++)
24216 {
24217
4/4
✓ Branch 0 taken 82557468 times.
✓ Branch 1 taken 2751733548 times.
✓ Branch 2 taken 11014244 times.
✓ Branch 3 taken 97 times.
2834291016 if (guysbuf[i].type==eeTRAP && guysbuf[i].attributes[1]
24218
2/2
✓ Branch 0 taken 11014341 times.
✓ Branch 1 taken 71543127 times.
82557468 && guys.idCount(i, screen))
24219 {
24220 97 setmapflag(scr, mTMPNORET);
24221 97 break;
24222 }
24223 2834290919 }
24224 5535803 }
24225 // clear enemies and open secret
24226
4/4
✓ Branch 0 taken 5458979 times.
✓ Branch 1 taken 191431 times.
✓ Branch 2 taken 5458123 times.
✓ Branch 3 taken 856 times.
5650410 if (!state.did_enemy_secret && (scr->flags2&fCLEARSECRET))
24227 {
24228 856 bool only16_31 = get_qr(qr_ENEMIES_SECRET_ONLY_16_31)?true:false;
24229 856 trigger_secrets_for_screen(TriggerSource::EnemiesScreenFlag, scr, only16_31);
24230
24231
4/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 750 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 101 times.
856 if (scr->flags4&fENEMYSCRTPERM && canPermSecret(cur_dmap, screen))
24232 {
24233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 101 times.
101 if (!(scr->flags5&fTEMPSECRETS)) setmapflag(scr, mSECRET);
24234 101 }
24235
24236 856 sfx(scr->secretsfx);
24237 856 state.did_enemy_secret = true;
24238 856 }
24239
1/2
✓ Branch 0 taken 5650410 times.
✗ Branch 1 not taken.
5650410 if(scr->flags9 & fENEMIES_STAY_DEAD)
24240 {
24241 if(!getmapflag(scr, mNO_ENEMIES_RETURN))
24242 setmapflag(scr, mNO_ENEMIES_RETURN);
24243 }
24244 5650410 }
24245 }
24246
24247 // doors
24248 14635678 bool has_shutter = false;
24249
24250
2/2
✓ Branch 0 taken 12603820 times.
✓ Branch 1 taken 54900490 times.
67504310 for (int i = 0; i < 4; i++)
24251 {
24252
2/2
✓ Branch 0 taken 52868632 times.
✓ Branch 1 taken 2031858 times.
54900490 if (scr->door[i]==dSHUTTER)
24253 {
24254 2031858 has_shutter = true;
24255
4/4
✓ Branch 0 taken 1991600 times.
✓ Branch 1 taken 40258 times.
✓ Branch 2 taken 1424 times.
✓ Branch 3 taken 1990176 times.
2031858 if (state.open_doors == 0 && state.loaded_enemies)
24256 {
24257
4/4
✓ Branch 0 taken 1657895 times.
✓ Branch 1 taken 332281 times.
✓ Branch 2 taken 1655472 times.
✓ Branch 3 taken 2423 times.
1990176 if (!(scr->flags&fSHUTTERS) && !hasmainguy)
24258 2423 state.open_doors=12;
24259 1990176 }
24260
2/2
✓ Branch 0 taken 32960 times.
✓ Branch 1 taken 8722 times.
41682 else if (state.open_doors < 0)
24261 8722 ++state.open_doors;
24262
2/2
✓ Branch 0 taken 30229 times.
✓ Branch 1 taken 2731 times.
32960 else if (--state.open_doors == 0)
24263 2731 openshutters(scr);
24264
24265 2031858 break;
24266 }
24267 52868632 }
24268
24269
10/10
✓ Branch 0 taken 12603820 times.
✓ Branch 1 taken 2031858 times.
✓ Branch 2 taken 12450579 times.
✓ Branch 3 taken 153241 times.
✓ Branch 4 taken 12030233 times.
✓ Branch 5 taken 420346 times.
✓ Branch 6 taken 11957713 times.
✓ Branch 7 taken 72520 times.
✓ Branch 8 taken 6603073 times.
✓ Branch 9 taken 5354640 times.
14635678 if (!has_shutter && !state.open_doors && state.loaded_enemies && !(scr->flags&fSHUTTERS) && !hasmainguy)
24270 {
24271 5354640 openshutters(scr);
24272 5354640 }
24273
24274 // set boss flag when boss is gone
24275
6/6
✓ Branch 0 taken 14208476 times.
✓ Branch 1 taken 427202 times.
✓ Branch 2 taken 204006 times.
✓ Branch 3 taken 14004470 times.
✓ Branch 4 taken 153974 times.
✓ Branch 5 taken 50032 times.
14635678 if (state.loaded_enemies && scr->flags11&efBOSS && !hasmainguy)
24276 {
24277 50032 game->lvlitems[dlevel]|=liBOSS;
24278 50032 stop_sfx(scr->bosssfx);
24279 50032 }
24280
24281 14635678 auto screen_handles = create_screen_handles(scr);
24282
24283
2/2
✓ Branch 0 taken 14559382 times.
✓ Branch 1 taken 76296 times.
14635678 if (getmapflag(screen, mCHEST)) // if special stuff done before
24284 {
24285 76296 remove_chests(screen_handles);
24286 76296 }
24287
24288
2/2
✓ Branch 0 taken 14633218 times.
✓ Branch 1 taken 2460 times.
14635678 if(getmapflag(screen, mLOCKEDCHEST)) // if special stuff done before
24289 {
24290 2460 remove_lockedchests(screen_handles);
24291 2460 }
24292
24293
2/2
✓ Branch 0 taken 14609477 times.
✓ Branch 1 taken 26201 times.
14635678 if(getmapflag(screen, mBOSSCHEST)) // if special stuff done before
24294 {
24295 26201 remove_bosschests(screen_handles);
24296 26201 }
24297
24298 14635678 clear_xdoors(screen_handles, true);
24299 14635678 clear_xstatecombos(screen_handles, true);
24300
24301
4/4
✓ Branch 0 taken 1375120 times.
✓ Branch 1 taken 13260558 times.
✓ Branch 2 taken 1375094 times.
✓ Branch 3 taken 26 times.
14635678 if (state.triggered_secrets && state.item_state == ScreenItemState::WhenTriggerSecrets)
24302 {
24303 26 int32_t Item=scr->item;
24304
24305
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 24 times.
26 if((!getmapflag(screen, mITEM) || (scr->flags9&fITEMRETURN)) && (scr->hasitem != 0))
24306 {
24307
3/4
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
24 auto [x, y] = translate_screen_coordinates_to_world(screen, scr->itemx, (scr->flags7&fITEMFALLS && isSideViewHero()) ? -170 : scr->itemy+1);
24308
4/8
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 24 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 24 times.
✗ Branch 7 not taken.
72 add_item_for_screen(screen, new item(x, y,
24309
6/10
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
24 (scr->flags7&fITEMFALLS && !isSideViewHero()) ? (zfix)170 : (zfix)0,
24310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].type==itype_triforcepiece ||
24311 24 (scr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((scr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
24312 24 }
24313
24314 26 state.item_state = ScreenItemState::None;
24315 26 }
24316 14635678 });
24317 14283256 }
24318
24319 // Returns 4 rpos indicated by all combinations of the coordinates, replacing duplicates with rpos_t::None
24320 13656240 static std::array<rpos_t, 4> getRposes(int32_t x1, int32_t y1, int32_t x2, int32_t y2)
24321 {
24322 std::array<rpos_t, 4> rposes;
24323 rpos_t tmp;
24324
24325 13656240 rposes[0] = COMBOPOS_REGION_B(x1,y1);
24326
24327 13656240 tmp = COMBOPOS_REGION_B(x1,y2);
24328
2/2
✓ Branch 0 taken 9877955 times.
✓ Branch 1 taken 3778285 times.
13656240 if (tmp == rposes[0])
24329 9877955 rposes[1] = rpos_t::None;
24330 3778285 else rposes[1] = tmp;
24331
24332 13656240 tmp = COMBOPOS_REGION_B(x2,y1);
24333
3/4
✓ Branch 0 taken 6634781 times.
✓ Branch 1 taken 7021459 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6634781 times.
13656240 if (tmp == rposes[0] || tmp == rposes[1])
24334 7021459 rposes[2] = rpos_t::None;
24335 6634781 else rposes[2] = tmp;
24336
24337 13656240 tmp = COMBOPOS_REGION_B(x2,y2);
24338
6/6
✓ Branch 0 taken 8605500 times.
✓ Branch 1 taken 5050740 times.
✓ Branch 2 taken 6634781 times.
✓ Branch 3 taken 1970719 times.
✓ Branch 4 taken 4827215 times.
✓ Branch 5 taken 1807566 times.
13656240 if (tmp == rposes[0] || tmp == rposes[1] || tmp == rposes[2])
24339 11848674 rposes[3] = rpos_t::None;
24340 1807566 else rposes[3] = tmp;
24341
24342 13656240 return rposes;
24343 }
24344
24345 14235858 void HeroClass::checkspecial2(int32_t *ls)
24346 {
24347
6/8
✓ Branch 0 taken 9981839 times.
✓ Branch 1 taken 4254019 times.
✓ Branch 2 taken 9717786 times.
✓ Branch 3 taken 264053 times.
✓ Branch 4 taken 9717786 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 9717786 times.
14235858 if(get_qr(qr_OLDSTYLEWARP) && !(diagonalMovement||NO_GRIDLOCK))
24348 {
24349 // Must run fairycircle stuff if currently active, otherwise hero gets stuck!
24350
2/2
✓ Branch 0 taken 21923 times.
✓ Branch 1 taken 9695863 times.
9717786 if (!fairyclk)
24351 {
24352
2/2
✓ Branch 0 taken 2922314 times.
✓ Branch 1 taken 6773549 times.
9695863 if(y.getInt()&7)
24353 2922314 return;
24354
24355
2/2
✓ Branch 0 taken 2955058 times.
✓ Branch 1 taken 3818491 times.
6773549 if(x.getInt()&7)
24356 3818491 return;
24357 2955058 }
24358 2976981 }
24359
24360
2/2
✓ Branch 0 taken 6059 times.
✓ Branch 1 taken 7488994 times.
7495053 if(toogam) return;
24361
24362 7488994 bool didstrig = false;
24363
24364
2/2
✓ Branch 0 taken 14977954 times.
✓ Branch 1 taken 7488954 times.
22466908 for(int32_t i=bigHitbox?0:8; i<16; i+=bigHitbox?15:7)
24365 {
24366
4/4
✓ Branch 0 taken 29955879 times.
✓ Branch 1 taken 14977914 times.
✓ Branch 2 taken 59911718 times.
✓ Branch 3 taken 29955839 times.
104845471 for(int32_t j=0; j<16; j+=15) for(int32_t k=0; k<2; k++)
24367 {
24368 59911718 int comboid = 0;
24369 mapscr* scr;
24370
2/2
✓ Branch 0 taken 29955839 times.
✓ Branch 1 taken 29955879 times.
59911718 if (k > 0)
24371 {
24372 29955839 auto ffc_handle = getFFCAt(x+j, y+i);
24373
2/2
✓ Branch 0 taken 29452309 times.
✓ Branch 1 taken 503530 times.
29955839 if (ffc_handle)
24374 {
24375 503530 comboid = ffc_handle->data();
24376 503530 scr = ffc_handle->scr;
24377 503530 }
24378 29955839 }
24379 else
24380 {
24381 29955879 auto rpos_handle = get_rpos_handle_for_world_xy(x+j, y+i, 0);
24382 29955879 comboid = rpos_handle.data();
24383 29955879 scr = rpos_handle.scr;
24384 }
24385 59911718 newcombo const& cmb = combobuf[comboid];
24386 59911718 int32_t stype = cmb.type;
24387 59911718 int32_t warpsound = cmb.attribytes[0];
24388
2/2
✓ Branch 0 taken 59911516 times.
✓ Branch 1 taken 202 times.
59911718 if(cmb.only_gentrig)
24389 202 stype = cNONE;
24390
2/2
✓ Branch 0 taken 59911684 times.
✓ Branch 1 taken 34 times.
59911718 if(stype==cSWARPA)
24391 {
24392
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1 times.
34 if(scr->flags5&fDIRECTSWARP)
24393 {
24394 1 setpit();
24395 1 }
24396
24397 34 sdir=dir;
24398 34 dowarp(scr,0,0,warpsound);
24399 34 return;
24400 }
24401
24402
2/2
✓ Branch 0 taken 59911679 times.
✓ Branch 1 taken 5 times.
59911684 if(stype==cSWARPB)
24403 {
24404
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(scr->flags5&fDIRECTSWARP)
24405 {
24406 setpit();
24407 }
24408
24409 5 sdir=dir;
24410 5 dowarp(scr,0,1,warpsound);
24411 5 return;
24412 }
24413
24414
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 59911678 times.
59911679 if(stype==cSWARPC)
24415 {
24416
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(scr->flags5&fDIRECTSWARP)
24417 {
24418 setpit();
24419 }
24420
24421 1 sdir=dir;
24422 1 dowarp(scr,0,2,warpsound);
24423 1 return;
24424 }
24425
24426
1/2
✓ Branch 0 taken 59911678 times.
✗ Branch 1 not taken.
59911678 if(stype==cSWARPD)
24427 {
24428 if(scr->flags5&fDIRECTSWARP)
24429 {
24430 setpit();
24431 }
24432
24433 sdir=dir;
24434 dowarp(scr,0,3,warpsound);
24435 return;
24436 }
24437
24438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59911678 times.
59911678 if(stype==cSWARPR)
24439 {
24440 if(scr->flags5&fDIRECTSWARP)
24441 {
24442 setpit();
24443 }
24444
24445 sdir=dir;
24446 dowarp(scr,0,(zc_oldrand()%4),warpsound);
24447 return;
24448 }
24449
24450 59911678 rpos_t rpos = COMBOPOS_REGION(x+j, y+i);
24451
4/4
✓ Branch 0 taken 59907528 times.
✓ Branch 1 taken 4150 times.
✓ Branch 2 taken 59909199 times.
✓ Branch 3 taken 2479 times.
59911678 if((stype==cSTRIGNOFLAG || stype==cSTRIGFLAG) && stepsecret!=rpos)
24452 {
24453 2479 auto rpos_handle = get_rpos_handle(rpos, 0);
24454
24455
3/4
✓ Branch 0 taken 895 times.
✓ Branch 1 taken 1584 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 895 times.
2479 if(stype==cSTRIGFLAG && canPermSecret(cur_dmap, rpos_handle.screen))
24456 {
24457
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 603 times.
895 if(!didstrig)
24458 {
24459 603 stepsecret = rpos;
24460
24461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 603 times.
603 if(!(rpos_handle.scr->flags5&fTEMPSECRETS))
24462 {
24463 603 setmapflag(rpos_handle.scr, mSECRET);
24464 603 }
24465 603 sfx(warpsound,pan((int32_t)x));
24466 603 trigger_secrets_for_screen(TriggerSource::Unspecified, rpos_handle.base_scr(), false);
24467 603 didstrig = true;
24468 603 }
24469 895 }
24470 else
24471 {
24472
2/2
✓ Branch 0 taken 680 times.
✓ Branch 1 taken 904 times.
1584 if(!didstrig)
24473 {
24474 904 stepsecret = rpos;
24475
24476 904 bool high16only = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
24477 904 trigger_secrets_for_screen(TriggerSource::Unspecified, rpos_handle.base_scr(), high16only);
24478 904 didstrig = true;
24479 904 sfx(warpsound,pan((int32_t)x));
24480 904 }
24481 }
24482 2479 }
24483 89867517 }
24484 14977914 }
24485
24486 7488954 bool RaftPass = false;//Special case for the raft, where only the raft stuff gets checked and nothing else.
24487
24488 // check if he's standing on a warp he just came out of
24489 // But if the QR is checked, it uses the old logic, cause some quests like Ballad of a Bloodline warp you onto a trigger and this new logic bricks that.
24490
2/2
✓ Branch 0 taken 2008545 times.
✓ Branch 1 taken 5480409 times.
7488954 if (!get_qr(qr_210_WARPRETURN))
24491 {
24492
6/6
✓ Branch 0 taken 5478435 times.
✓ Branch 1 taken 1974 times.
✓ Branch 2 taken 359240 times.
✓ Branch 3 taken 5119195 times.
✓ Branch 4 taken 55319 times.
✓ Branch 5 taken 303921 times.
5480409 if(((int32_t)y>=warpy-8&&(int32_t)y<=warpy+7)&&warpy!=-1)
24493 {
24494
5/6
✓ Branch 0 taken 302857 times.
✓ Branch 1 taken 1064 times.
✓ Branch 2 taken 301358 times.
✓ Branch 3 taken 1499 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 301358 times.
303921 if(((int32_t)x>=warpx-8&&(int32_t)x<=warpx+7)&&warpx!=-1)
24495 {
24496
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 301353 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
301358 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
24497 301358 else return;
24498 }
24499 2563 }
24500 5179051 }
24501 else
24502 {
24503
2/2
✓ Branch 0 taken 1677137 times.
✓ Branch 1 taken 331408 times.
2008545 if(TRUNCATE_HALF_TILE(int32_t(y))==warpy)
24504 {
24505
2/2
✓ Branch 0 taken 4076 times.
✓ Branch 1 taken 327332 times.
331408 if(x==warpx)
24506 {
24507
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 327332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
327332 if (get_qr(qr_BETTER_RAFT_2) && dir != up) RaftPass = true;
24508 327332 else return;
24509 }
24510 4076 }
24511 }
24512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6860264 times.
6860264 if (!RaftPass) warpy=-1;
24513
24514
6/6
✓ Branch 0 taken 6852858 times.
✓ Branch 1 taken 7406 times.
✓ Branch 2 taken 324324 times.
✓ Branch 3 taken 6528534 times.
✓ Branch 4 taken 238314 times.
✓ Branch 5 taken 86010 times.
6860264 if(((int32_t)y<raftwarpy-(get_qr(qr_BETTER_RAFT_2)?12:8)||(int32_t)y>raftwarpy+(get_qr(qr_BETTER_RAFT_2)?3:7))||raftwarpy==-1)
24515 {
24516 6621950 raftwarpy = -1;
24517 6621950 }
24518
6/6
✓ Branch 0 taken 6854210 times.
✓ Branch 1 taken 6054 times.
✓ Branch 2 taken 314810 times.
✓ Branch 3 taken 6539400 times.
✓ Branch 4 taken 239696 times.
✓ Branch 5 taken 75114 times.
6860264 if (((int32_t)x<raftwarpx - 8 || (int32_t)x>raftwarpx + 7) || raftwarpx == -1)
24519 {
24520 6620568 raftwarpx = -1;
24521 6620568 }
24522 6860264 int32_t tx=x;
24523 6860264 int32_t ty=y;
24524
24525 6860264 int32_t flag=0;
24526 6860264 int32_t flag2=0;
24527 6860264 int32_t flag3=0;
24528 6860264 mapscr* flag_scr=nullptr;
24529 6860264 mapscr* flag2_scr=nullptr;
24530 6860264 mapscr* flag3_scr=nullptr;
24531 6860264 mapscr* scrs[4]={};
24532 6860264 rpos_handle_t rpos_handles[4];
24533 6860264 int32_t type=0;
24534 6860264 int32_t water=0;
24535 6860264 int32_t index = 0;
24536
24537 6860264 bool setsave=false;
24538 6860264 int32_t warpsfx2 = 0;
24539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6860264 times.
6860264 if (RaftPass) goto RaftingStuff;
24540
24541 int32_t x1,x2,y1,y2;
24542 6860264 x1 = tx;
24543 6860264 x2 = tx+15;
24544 6860264 y1 = ty;
24545 6860264 y2 = ty+15;
24546
24547
4/6
✓ Branch 0 taken 2514335 times.
✓ Branch 1 taken 4345929 times.
✓ Branch 2 taken 2514335 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2514335 times.
6860264 if((diagonalMovement||NO_GRIDLOCK))
24548 {
24549 4345929 x1 = tx+4;
24550 4345929 x2 = tx+11;
24551 4345929 y1 = ty+4;
24552 4345929 y2 = ty+11;
24553 4345929 }
24554
24555 int32_t types[4];
24556 6860264 types[0]=types[1]=types[2]=types[3]=-1;
24557 int32_t cids[4];
24558 int32_t ffcids[4];
24559 6860264 cids[0]=cids[1]=cids[2]=cids[3]=-1;
24560 6860264 ffcids[0]=ffcids[1]=ffcids[2]=ffcids[3]=-1;
24561 //
24562 // First, let's find flag1 (combo flag), flag2 (inherent flag) and flag3 (FFC flag)...
24563 //
24564
24565 6860264 rpos_handles[0] = get_rpos_handle_for_world_xy(x1, y1, 0);
24566 6860264 rpos_handles[1] = get_rpos_handle_for_world_xy(x1, y2, 0);
24567 6860264 rpos_handles[2] = get_rpos_handle_for_world_xy(x2, y1, 0);
24568 6860264 rpos_handles[3] = get_rpos_handle_for_world_xy(x2, y2, 0);
24569
24570 6860264 types[0] = rpos_handles[0].sflag();
24571 6860264 types[1] = rpos_handles[1].sflag();
24572 6860264 types[2] = rpos_handles[2].sflag();
24573 6860264 types[3] = rpos_handles[3].sflag();
24574
24575 6860264 flag_scr = rpos_handles[0].scr;
24576
24577 //MAPFFCOMBO
24578
24579
6/6
✓ Branch 0 taken 6639388 times.
✓ Branch 1 taken 220876 times.
✓ Branch 2 taken 6611900 times.
✓ Branch 3 taken 27488 times.
✓ Branch 4 taken 85235 times.
✓ Branch 5 taken 6526665 times.
6860264 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24580 6526665 flag = types[0];
24581 // 2.10 compatibility...
24582
10/10
✓ Branch 0 taken 148449 times.
✓ Branch 1 taken 185150 times.
✓ Branch 2 taken 122271 times.
✓ Branch 3 taken 26178 times.
✓ Branch 4 taken 108406 times.
✓ Branch 5 taken 13865 times.
✓ Branch 6 taken 108310 times.
✓ Branch 7 taken 96 times.
✓ Branch 8 taken 98 times.
✓ Branch 9 taken 108212 times.
333599 else if(y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24583 14059 flag = types[0];
24584
24585
24586 6860264 types[0] = rpos_handles[0].cflag();
24587 6860264 types[1] = rpos_handles[1].cflag();
24588 6860264 types[2] = rpos_handles[2].cflag();
24589 6860264 types[3] = rpos_handles[3].cflag();
24590 6860264 flag2_scr = rpos_handles[0].scr;
24591
24592
6/6
✓ Branch 0 taken 6799312 times.
✓ Branch 1 taken 60952 times.
✓ Branch 2 taken 6792249 times.
✓ Branch 3 taken 7063 times.
✓ Branch 4 taken 17768 times.
✓ Branch 5 taken 6774481 times.
6860264 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24593 6774481 flag2 = types[0];
24594
9/12
✓ Branch 0 taken 20949 times.
✓ Branch 1 taken 64834 times.
✓ Branch 2 taken 3350 times.
✓ Branch 3 taken 17599 times.
✓ Branch 4 taken 2740 times.
✓ Branch 5 taken 610 times.
✓ Branch 6 taken 2740 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2740 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2740 times.
85783 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24595 flag2 = types[0];
24596
24597 {
24598 6860264 auto ffc_handle_1 = getFFCAt(x1, y1);
24599 6860264 auto ffc_handle_2 = getFFCAt(x1, y2);
24600 6860264 auto ffc_handle_3 = getFFCAt(x2, y1);
24601 6860264 auto ffc_handle_4 = getFFCAt(x2, y2);
24602
24603
2/2
✓ Branch 0 taken 174885 times.
✓ Branch 1 taken 6685379 times.
6860264 types[0] = ffc_handle_1 ? ffc_handle_1->cflag() : 0;
24604
2/2
✓ Branch 0 taken 129891 times.
✓ Branch 1 taken 6730373 times.
6860264 types[1] = ffc_handle_2 ? ffc_handle_2->cflag() : 0;
24605
2/2
✓ Branch 0 taken 174314 times.
✓ Branch 1 taken 6685950 times.
6860264 types[2] = ffc_handle_3 ? ffc_handle_3->cflag() : 0;
24606
2/2
✓ Branch 0 taken 130473 times.
✓ Branch 1 taken 6729791 times.
6860264 types[3] = ffc_handle_4 ? ffc_handle_4->cflag() : 0;
24607
24608
2/2
✓ Branch 0 taken 174885 times.
✓ Branch 1 taken 6685379 times.
6860264 if (ffc_handle_1)
24609 174885 flag3_scr = ffc_handle_1->scr;
24610
2/2
✓ Branch 0 taken 21249 times.
✓ Branch 1 taken 6664130 times.
6685379 else if (ffc_handle_2)
24611 21249 flag3_scr = ffc_handle_2->scr;
24612
2/2
✓ Branch 0 taken 18021 times.
✓ Branch 1 taken 6646109 times.
6664130 else if (ffc_handle_3)
24613 18021 flag3_scr = ffc_handle_3->scr;
24614
2/2
✓ Branch 0 taken 6641239 times.
✓ Branch 1 taken 4870 times.
6646109 else if (ffc_handle_4)
24615 4870 flag3_scr = ffc_handle_4->scr;
24616 }
24617
24618 //
24619
24620
6/6
✓ Branch 0 taken 6859663 times.
✓ Branch 1 taken 601 times.
✓ Branch 2 taken 6859516 times.
✓ Branch 3 taken 147 times.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 6859501 times.
6860264 if(types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
24621 6859501 flag3 = types[0];
24622
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 763 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
763 else if(!get_qr(qr_FAIRY_FLAG_COMPAT) && y.getInt()%16==8 && types[0]==types[2] && (types[0]==mfFAIRY || types[0]==mfMAGICFAIRY || types[0]==mfALLFAIRY))
24623 flag3 = types[0];
24624
24625 //
24626 // Now, let's check for warp combos...
24627 //
24628
24629 //
24630
24631 6860264 cids[0] = rpos_handles[0].data();
24632 6860264 cids[1] = rpos_handles[1].data();
24633 6860264 cids[2] = rpos_handles[2].data();
24634 6860264 cids[3] = rpos_handles[3].data();
24635
24636 6860264 types[0] = rpos_handles[0].ctype();
24637
2/2
✓ Branch 0 taken 6685379 times.
✓ Branch 1 taken 174885 times.
6860264 if (auto ffc_handle = getFFCAt(x1, y1))
24638 {
24639 174885 types[0] = ffc_handle->ctype();
24640 174885 cids[0] = ffc_handle->data();
24641 174885 }
24642
24643 6860264 types[1] = rpos_handles[1].ctype();
24644
2/2
✓ Branch 0 taken 6730373 times.
✓ Branch 1 taken 129891 times.
6860264 if (auto ffc_handle = getFFCAt(x1, y2))
24645 {
24646 129891 types[1] = ffc_handle->ctype();
24647 129891 cids[1] = ffc_handle->data();
24648 129891 }
24649
24650 6860264 types[2] = rpos_handles[2].ctype();
24651
2/2
✓ Branch 0 taken 6685950 times.
✓ Branch 1 taken 174314 times.
6860264 if (auto ffc_handle = getFFCAt(x2, y1))
24652 {
24653 174314 types[2] = ffc_handle->ctype();
24654 174314 cids[2] = ffc_handle->data();
24655 174314 }
24656
24657 6860264 types[3] = rpos_handles[3].ctype();
24658
2/2
✓ Branch 0 taken 6729791 times.
✓ Branch 1 taken 130473 times.
6860264 if (auto ffc_handle = getFFCAt(x2, y2))
24659 {
24660 130473 types[3] = ffc_handle->ctype();
24661 130473 cids[3] = ffc_handle->data();
24662 130473 }
24663
24664 // Change B, C and D warps into A, for the comparison below...
24665
2/2
✓ Branch 0 taken 27441056 times.
✓ Branch 1 taken 6860264 times.
34301320 for(int32_t i=0; i<4; i++)
24666 {
24667
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 27440732 times.
27441056 if(combobuf[cids[i]].only_gentrig)
24668 {
24669 324 types[i] = cNONE;
24670 324 continue;
24671 }
24672
2/2
✓ Branch 0 taken 6937 times.
✓ Branch 1 taken 27433795 times.
27440732 if(types[i]==cCAVE)
24673 {
24674 6937 index=0;
24675 6937 warpsfx2 = combobuf[cids[i]].attribytes[0];
24676 6937 }
24677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27433795 times.
27433795 else if(types[i]==cCAVEB)
24678 {
24679 types[i]=cCAVE;
24680 index=1;
24681 warpsfx2 = combobuf[cids[i]].attribytes[0];
24682 }
24683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27433795 times.
27433795 else if(types[i]==cCAVEC)
24684 {
24685 types[i]=cCAVE;
24686 index=2;
24687 warpsfx2 = combobuf[cids[i]].attribytes[0];
24688 }
24689
1/2
✓ Branch 0 taken 27433795 times.
✗ Branch 1 not taken.
27433795 else if(types[i]==cCAVED)
24690 {
24691 types[i]=cCAVE;
24692 index=3;
24693 warpsfx2 = combobuf[cids[i]].attribytes[0];
24694 }
24695
24696
2/2
✓ Branch 0 taken 9519 times.
✓ Branch 1 taken 27431213 times.
27440732 if(types[i]==cPIT)
24697 {
24698 9519 index=0;
24699 9519 warpsfx2 = combobuf[cids[i]].attribytes[0];
24700 9519 }
24701
2/2
✓ Branch 0 taken 5708 times.
✓ Branch 1 taken 27425505 times.
27431213 else if(types[i]==cPITB)
24702 {
24703 5708 types[i]=cPIT;
24704 5708 warpsfx2 = combobuf[cids[i]].attribytes[0];
24705 5708 index=1;
24706 5708 }
24707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27425505 times.
27425505 else if(types[i]==cPITC)
24708 {
24709 types[i]=cPIT;
24710 warpsfx2 = combobuf[cids[i]].attribytes[0];
24711 index=2;
24712 }
24713
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 27425499 times.
27425505 else if(types[i]==cPITD)
24714 {
24715 6 types[i]=cPIT;
24716 6 warpsfx2 = combobuf[cids[i]].attribytes[0];
24717 6 index=3;
24718 6 }
24719
1/2
✓ Branch 0 taken 27425499 times.
✗ Branch 1 not taken.
27425499 else if(types[i]==cPITR)
24720 {
24721 types[i]=cPIT;
24722 warpsfx2 = combobuf[cids[i]].attribytes[0];
24723 index=zc_oldrand()%4;
24724 }
24725
24726
2/2
✓ Branch 0 taken 32729 times.
✓ Branch 1 taken 27408003 times.
27440732 if(types[i]==cSTAIR)
24727 {
24728 32729 index=0;
24729 32729 warpsfx2 = combobuf[cids[i]].attribytes[0];
24730 32729 }
24731
2/2
✓ Branch 0 taken 1685 times.
✓ Branch 1 taken 27406318 times.
27408003 else if(types[i]==cSTAIRB)
24732 {
24733 1685 types[i]=cSTAIR;
24734 1685 warpsfx2 = combobuf[cids[i]].attribytes[0];
24735 1685 index=1;
24736 1685 }
24737
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 27406200 times.
27406318 else if(types[i]==cSTAIRC)
24738 {
24739 118 types[i]=cSTAIR;
24740 118 warpsfx2 = combobuf[cids[i]].attribytes[0];
24741 118 index=2;
24742 118 }
24743
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 27405997 times.
27406200 else if(types[i]==cSTAIRD)
24744 {
24745 203 types[i]=cSTAIR;
24746 203 warpsfx2 = combobuf[cids[i]].attribytes[0];
24747 203 index=3;
24748 203 }
24749
1/2
✓ Branch 0 taken 27405997 times.
✗ Branch 1 not taken.
27405997 else if(types[i]==cSTAIRR)
24750 {
24751 types[i]=cSTAIR;
24752 index=zc_oldrand()%4;
24753 warpsfx2 = combobuf[cids[i]].attribytes[0];
24754 }
24755
24756
2/2
✓ Branch 0 taken 6587 times.
✓ Branch 1 taken 27434145 times.
27440732 if(types[i]==cCAVE2)
24757 {
24758 6587 index=0;
24759 6587 warpsfx2 = combobuf[cids[i]].attribytes[0];
24760 6587 }
24761
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 27433812 times.
27434145 else if(types[i]==cCAVE2B)
24762 {
24763 333 types[i]=cCAVE2;
24764 333 index=1;
24765 333 warpsfx2 = combobuf[cids[i]].attribytes[0];
24766 333 }
24767
2/2
✓ Branch 0 taken 163 times.
✓ Branch 1 taken 27433649 times.
27433812 else if(types[i]==cCAVE2C)
24768 {
24769 163 types[i]=cCAVE2;
24770 163 warpsfx2 = combobuf[cids[i]].attribytes[0];
24771 163 index=2;
24772 163 }
24773
1/2
✓ Branch 0 taken 27433649 times.
✗ Branch 1 not taken.
27433649 else if(types[i]==cCAVE2D)
24774 {
24775 types[i]=cCAVE2;
24776 warpsfx2 = combobuf[cids[i]].attribytes[0];
24777 index=3;
24778 }
24779
24780
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 27440577 times.
27440732 if(types[i]==cSWIMWARP)
24781 {
24782 155 index=0;
24783 155 warpsfx2 = combobuf[cids[i]].attribytes[0];
24784 155 }
24785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27440577 times.
27440577 else if(types[i]==cSWIMWARPB)
24786 {
24787 types[i]=cSWIMWARP;
24788 warpsfx2 = combobuf[cids[i]].attribytes[0];
24789 index=1;
24790 }
24791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27440577 times.
27440577 else if(types[i]==cSWIMWARPC)
24792 {
24793 types[i]=cSWIMWARP;
24794 warpsfx2 = combobuf[cids[i]].attribytes[0];
24795 index=2;
24796 }
24797
1/2
✓ Branch 0 taken 27440577 times.
✗ Branch 1 not taken.
27440577 else if(types[i]==cSWIMWARPD)
24798 {
24799 types[i]=cSWIMWARP;
24800 warpsfx2 = combobuf[cids[i]].attribytes[0];
24801 index=3;
24802 }
24803
24804
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 27440137 times.
27440732 if(types[i]==cDIVEWARP)
24805 {
24806 595 index=0;
24807 595 warpsfx2 = combobuf[cids[i]].attribytes[0];
24808 595 }
24809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27440137 times.
27440137 else if(types[i]==cDIVEWARPB)
24810 {
24811 types[i]=cDIVEWARP;
24812 warpsfx2 = combobuf[cids[i]].attribytes[0];
24813 index=1;
24814 }
24815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27440137 times.
27440137 else if(types[i]==cDIVEWARPC)
24816 {
24817 types[i]=cDIVEWARP;
24818 warpsfx2 = combobuf[cids[i]].attribytes[0];
24819 index=2;
24820 }
24821
1/2
✓ Branch 0 taken 27440137 times.
✗ Branch 1 not taken.
27440137 else if(types[i]==cDIVEWARPD)
24822 {
24823 types[i]=cDIVEWARP;
24824 warpsfx2 = combobuf[cids[i]].attribytes[0];
24825 index=3;
24826 }
24827
24828
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 27432460 times.
27440732 if(types[i]==cSTEP) warpsfx2 = combobuf[cids[i]].attribytes[0];
24829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27432460 times.
27432460 else if(types[i]==cSTEPSAME) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0];}
24830
2/2
✓ Branch 0 taken 27432316 times.
✓ Branch 1 taken 144 times.
27432460 else if(types[i]==cSTEPALL) { types[i]=cSTEP; warpsfx2 = combobuf[cids[i]].attribytes[0]; }
24831 27440732 }
24832
24833 // Special case for step combos; otherwise, they act oddly in some cases
24834
8/8
✓ Branch 0 taken 6272904 times.
✓ Branch 1 taken 587360 times.
✓ Branch 2 taken 6209011 times.
✓ Branch 3 taken 63893 times.
✓ Branch 4 taken 1452 times.
✓ Branch 5 taken 649801 times.
✓ Branch 6 taken 129419 times.
✓ Branch 7 taken 127967 times.
6860264 if((types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])||(types[1]==cSTEP&&types[3]==cSTEP))
24835 {
24836
7/8
✓ Branch 0 taken 6049787 times.
✓ Branch 1 taken 29805 times.
✓ Branch 2 taken 6049787 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1589 times.
✓ Branch 5 taken 6048198 times.
✓ Branch 6 taken 460 times.
✓ Branch 7 taken 1129 times.
6338430 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
24837 6049327 type = types[1];
24838 6079592 }
24839
24840 //Generic Step
24841
7/8
✓ Branch 0 taken 6827726 times.
✓ Branch 1 taken 29634 times.
✓ Branch 2 taken 6827726 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1930 times.
✓ Branch 5 taken 6825796 times.
✓ Branch 6 taken 796 times.
✓ Branch 7 taken 1134 times.
6857360 if(action!=freeze&&action!=sideswimfreeze&&(!msg_active || !get_qr(qr_MSGFREEZE)))
24842 {
24843
4/6
✓ Branch 0 taken 2491698 times.
✓ Branch 1 taken 4335232 times.
✓ Branch 2 taken 2491698 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2491698 times.
6826930 auto rposes = diagonalMovement||NO_GRIDLOCK ?
24844 4335232 getRposes(tx+4, ty+4, tx+11, ty+11) :
24845 2491698 getRposes(tx+4, ty+4, tx+11, ty+11);
24846 6826930 auto sensRposes = getRposes(tx, ty+(bigHitbox?0:8), tx+15, ty+15);
24847 6826930 int32_t xPoses[4] = {tx + 4, tx + 11, tx, tx + 15};
24848 6826930 int32_t yPoses[4] = {ty + 4, ty + 11, ty+(bigHitbox?0:8), ty + 15};
24849
24850 6826930 bool hasStep[4] = {false};
24851
2/2
✓ Branch 0 taken 27307720 times.
✓ Branch 1 taken 6826930 times.
34134650 for(auto p = 0; p < 4; ++p)
24852 {
24853
2/2
✓ Branch 0 taken 12763201 times.
✓ Branch 1 taken 14544519 times.
27307720 if (rposes[p] == rpos_t::None) continue;
24854
24855
2/2
✓ Branch 0 taken 12758239 times.
✓ Branch 1 taken 89312786 times.
102071025 for (auto lyr = 0; lyr < 7; ++lyr)
24856 {
24857 89312786 auto rpos_handle = get_rpos_handle(rposes[p], lyr);
24858
4/4
✓ Branch 0 taken 89047010 times.
✓ Branch 1 taken 265776 times.
✓ Branch 2 taken 89050860 times.
✓ Branch 3 taken 261926 times.
89312786 if ((z > 0 || fakez > 0) && !(rpos_handle.base_scr()->flags2 & fAIRCOMBOS))
24859 261926 continue;
24860 89050860 auto& cmb = rpos_handle.combo();
24861
2/2
✓ Branch 0 taken 89045898 times.
✓ Branch 1 taken 5246030 times.
94291928 for(size_t idx = 0; idx < cmb.triggers.size(); ++idx)
24862 {
24863 5246030 auto& trig = cmb.triggers[idx];
24864
4/6
✓ Branch 0 taken 5246030 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5246030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5241068 times.
✓ Branch 5 taken 4962 times.
10492060 if (trig.trigger_flags.any({TRIGFLAG_STEP,TRIGFLAG_STEPSENS})
24865
2/2
✓ Branch 0 taken 4962 times.
✓ Branch 1 taken 5241068 times.
5246030 || types[p] == cSTEP)
24866 {
24867 4962 hasStep[p] = true;
24868 4962 break;
24869 }
24870 5241068 }
24871
2/2
✓ Branch 0 taken 89045898 times.
✓ Branch 1 taken 4962 times.
89050860 if(hasStep[p])
24872 4962 break;
24873 89045898 }
24874 12763201 }
24875 6826930 bool canNormalStep = true;
24876
2/2
✓ Branch 0 taken 1499 times.
✓ Branch 1 taken 6832495 times.
6833994 for(auto p = 0; p < 4; ++p)
24877 {
24878
2/2
✓ Branch 0 taken 6828813 times.
✓ Branch 1 taken 3682 times.
6832495 if(rposes[p] == rpos_t::None) continue;
24879
2/2
✓ Branch 0 taken 3382 times.
✓ Branch 1 taken 6825431 times.
6828813 if(!hasStep[p])
24880 {
24881 6825431 canNormalStep = false;
24882 6825431 break;
24883 }
24884 3382 }
24885
2/2
✓ Branch 0 taken 27307720 times.
✓ Branch 1 taken 6826930 times.
34134650 for (auto p = 0; p < 4; ++p)
24886 {
24887
2/2
✓ Branch 0 taken 191154040 times.
✓ Branch 1 taken 27307720 times.
218461760 for (auto lyr = 0; lyr < 7; ++lyr)
24888 {
24889
2/2
✓ Branch 0 taken 101811633 times.
✓ Branch 1 taken 89342407 times.
191154040 if (rposes[p] != rpos_t::None)
24890 {
24891 89342407 auto rpos_handle = get_rpos_handle(rposes[p], lyr);
24892
5/8
✓ Branch 0 taken 89324963 times.
✓ Branch 1 taken 17444 times.
✓ Branch 2 taken 17444 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 89324963 times.
✓ Branch 5 taken 17444 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
89362859 bool did_trig = canNormalStep && trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
24893 3008 return trig.trigger_flags.get(TRIGFLAG_STEP);
24894 });
24895
4/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 89342292 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 58 times.
89342407 if (did_trig && rposes[p] == sensRposes[p]) continue;
24896 89342349 }
24897
2/2
✓ Branch 0 taken 99391936 times.
✓ Branch 1 taken 91762046 times.
191153982 if (sensRposes[p] != rpos_t::None)
24898 {
24899 91762046 auto rpos_handle = get_rpos_handle(sensRposes[p], lyr);
24900
1/2
✓ Branch 0 taken 91762046 times.
✗ Branch 1 not taken.
97903049 trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
24901 6141003 return trig.trigger_flags.get(TRIGFLAG_STEPSENS);
24902 });
24903 91762046 }
24904 191153982 }
24905 27307720 }
24906
24907 207042239 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
24908 200215309 bool found = false;
24909
2/2
✓ Branch 0 taken 400430618 times.
✓ Branch 1 taken 200215309 times.
600645927 for (int xch = 0; xch < 2; ++xch)
24910 {
24911
2/2
✓ Branch 0 taken 800861236 times.
✓ Branch 1 taken 400430618 times.
1201291854 for(int ych = 0; ych < 2; ++ych)
24912 {
24913
2/2
✓ Branch 0 taken 800245544 times.
✓ Branch 1 taken 615692 times.
800861236 if (ffcIsAt(ffc_handle, xPoses[xch], yPoses[ych]))
24914 {
24915 615692 found = true;
24916 615692 }
24917 800861236 }
24918 400430618 }
24919
2/2
✓ Branch 0 taken 199988968 times.
✓ Branch 1 taken 226341 times.
200215309 if (found)
24920 {
24921
1/2
✓ Branch 0 taken 226341 times.
✗ Branch 1 not taken.
227172 trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
24922
2/4
✓ Branch 0 taken 831 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 831 times.
831 return trig.trigger_flags.any({TRIGFLAG_STEP,TRIGFLAG_STEPSENS});
24923 });
24924 226341 }
24925 200215309 });
24926 6826930 }
24927
24928
2/2
✓ Branch 0 taken 6854980 times.
✓ Branch 1 taken 2380 times.
6857360 if(isDiving()) //Dive-> triggerflag
24929 {
24930 2380 rpos_t rpos = COMBOPOS_REGION(x+8,y+8);
24931 2380 int x1=x,x2=x+15,y1=y+(bigHitbox?0:8),y2=y+15;
24932 2380 int xposes[] = {x1,x1,x2,x2};
24933 2380 int yposes[] = {y1,y2,y1,y2};
24934 2380 auto rposes = getRposes(x1,y1,x2,y2);
24935
2/2
✓ Branch 0 taken 16660 times.
✓ Branch 1 taken 2380 times.
19040 for(auto lyr = 0; lyr < 7; ++lyr)
24936 {
24937 16660 bool didtrig = false;
24938 16660 auto rpos_handle = get_rpos_handle(rpos, lyr);
24939 16660 auto& cmb = rpos_handle.combo();
24940 16660 auto cid = rpos_handle.data();
24941
1/2
✓ Branch 0 taken 16660 times.
✗ Branch 1 not taken.
18851 didtrig = trig_each_combo_trigger(rpos_handle, [&](combo_trigger const& trig){
24942 2191 return trig.trigger_flags.get(TRIGFLAG_DIVETRIG);
24943 });
24944
2/2
✓ Branch 0 taken 66640 times.
✓ Branch 1 taken 16660 times.
83300 for(auto q = 0; q < 4; ++q)
24945 {
24946
2/2
✓ Branch 0 taken 33593 times.
✓ Branch 1 taken 33047 times.
66640 if(rposes[q] == rpos_t::None) continue;
24947
3/4
✓ Branch 0 taken 16660 times.
✓ Branch 1 taken 16933 times.
✓ Branch 2 taken 16660 times.
✗ Branch 3 not taken.
33593 if(rposes[q] == rpos && didtrig) continue;
24948
24949 33593 auto rpos_handle_2 = get_rpos_handle(rposes[q], lyr);
24950
1/2
✓ Branch 0 taken 33593 times.
✗ Branch 1 not taken.
38102 trig_each_combo_trigger(rpos_handle_2, [&](combo_trigger const& trig){
24951 4509 return trig.trigger_flags.get(TRIGFLAG_DIVESENSTRIG);
24952 });
24953 33593 }
24954 16660 }
24955
24956 68688 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
24957
2/2
✓ Branch 0 taken 66272 times.
✓ Branch 1 taken 36 times.
66308 if(ffcIsAt(ffc_handle, x+8, y+8))
24958 {
24959
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
36 if(trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
24960 return trig.trigger_flags.get(TRIGFLAG_DIVETRIG);
24961 })) return;
24962 36 }
24963
2/2
✓ Branch 0 taken 66308 times.
✓ Branch 1 taken 265232 times.
331540 for(auto q = 0; q < 4; ++q)
24964 {
24965
2/2
✓ Branch 0 taken 265143 times.
✓ Branch 1 taken 89 times.
265232 if(ffcIsAt(ffc_handle, xposes[q], yposes[q]))
24966 {
24967
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(trig_each_combo_trigger(ffc_handle, [&](combo_trigger const& trig){
24968 return trig.trigger_flags.get(TRIGFLAG_DIVESENSTRIG);
24969 })) break;
24970 89 }
24971 265232 }
24972 66308 });
24973 2380 }
24974
24975 //
24976 // Now, let's check for Save combos...
24977 //
24978 6857360 x1 = tx+4;
24979 6857360 x2 = tx+11;
24980 6857360 y1 = ty+4;
24981 6857360 y2 = ty+11;
24982
24983 6857360 rpos_handles[0] = get_rpos_handle_for_world_xy(x1, y1, 0);
24984 6857360 rpos_handles[1] = get_rpos_handle_for_world_xy(x1, y2, 0);
24985 6857360 rpos_handles[2] = get_rpos_handle_for_world_xy(x2, y1, 0);
24986 6857360 rpos_handles[3] = get_rpos_handle_for_world_xy(x2, y2, 0);
24987
24988 6857360 cids[0] = rpos_handles[0].data();
24989 6857360 cids[1] = rpos_handles[1].data();
24990 6857360 cids[2] = rpos_handles[2].data();
24991 6857360 cids[3] = rpos_handles[3].data();
24992
24993 6857360 types[0] = rpos_handles[0].ctype();
24994
2/2
✓ Branch 0 taken 6682498 times.
✓ Branch 1 taken 174862 times.
6857360 if (auto ffc_handle = getFFCAt(x1, y1))
24995 {
24996 174862 types[0] = ffc_handle->ctype();
24997 174862 cids[0] = ffc_handle->data();
24998 174862 }
24999
25000 6857360 types[1] = rpos_handles[1].ctype();
25001
2/2
✓ Branch 0 taken 6727455 times.
✓ Branch 1 taken 129905 times.
6857360 if (auto ffc_handle = getFFCAt(x1, y2))
25002 {
25003 129905 types[1] = ffc_handle->ctype();
25004 129905 cids[1] = ffc_handle->data();
25005 129905 }
25006
25007 6857360 types[2] = rpos_handles[2].ctype();
25008
2/2
✓ Branch 0 taken 6683061 times.
✓ Branch 1 taken 174299 times.
6857360 if (auto ffc_handle = getFFCAt(x2, y1))
25009 {
25010 174299 types[2] = ffc_handle->ctype();
25011 174299 cids[2] = ffc_handle->data();
25012 174299 }
25013
25014 6857360 types[3] = rpos_handles[3].ctype();
25015
2/2
✓ Branch 0 taken 6726872 times.
✓ Branch 1 taken 130488 times.
6857360 if (auto ffc_handle = getFFCAt(x2, y2))
25016 {
25017 130488 types[3] = ffc_handle->ctype();
25018 130488 cids[3] = ffc_handle->data();
25019 130488 }
25020
25021
2/2
✓ Branch 0 taken 6857360 times.
✓ Branch 1 taken 27441056 times.
34298416 for(int32_t i=0; i<4; i++)
25022 {
25023
2/2
✓ Branch 0 taken 27440732 times.
✓ Branch 1 taken 324 times.
27441056 if(combobuf[cids[i]].only_gentrig)
25024 {
25025
2/4
✓ Branch 0 taken 324 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 324 times.
324 if(types[i] == cSAVE || types[i] == cSAVE2)
25026 {
25027 types[i] = cNONE;
25028 setsave = false;
25029 break;
25030 }
25031 324 }
25032
2/2
✓ Branch 0 taken 27439770 times.
✓ Branch 1 taken 1286 times.
27441056 if(types[i]==cSAVE) setsave=true;
25033
25034
1/2
✓ Branch 0 taken 27441056 times.
✗ Branch 1 not taken.
27441056 if(types[i]==cSAVE2) setsave=true;
25035 27441056 }
25036
25037
8/8
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 6856929 times.
✓ Branch 2 taken 343 times.
✓ Branch 3 taken 88 times.
✓ Branch 4 taken 335 times.
✓ Branch 5 taken 8 times.
✓ Branch 6 taken 106 times.
✓ Branch 7 taken 229 times.
6857360 if(setsave && types[0]==types[1]&&types[2]==types[3]&&types[1]==types[2])
25038 {
25039 229 last_savepoint_id = cids[0];
25040 229 type = types[0];
25041 229 }
25042 //
25043 // Now, let's check for Drowning combos...
25044 //
25045
4/4
✓ Branch 0 taken 2625640 times.
✓ Branch 1 taken 4231720 times.
✓ Branch 2 taken 2904 times.
✓ Branch 3 taken 2622736 times.
6857360 if(get_qr(qr_DROWN) || CanSideSwim())
25046 {
25047 4234624 y1 = ty+9;
25048 4234624 y2 = ty+15;
25049
2/2
✓ Branch 0 taken 1092995 times.
✓ Branch 1 taken 3141629 times.
4234624 if (get_qr(qr_SMARTER_WATER))
25050 {
25051
4/4
✓ Branch 0 taken 11287 times.
✓ Branch 1 taken 1081708 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 8892 times.
1101909 if (iswaterex_z3(0, -1, x1, y1, true, false) &&
25052
2/2
✓ Branch 0 taken 10186 times.
✓ Branch 1 taken 1101 times.
11287 iswaterex_z3(0, -1, x1, y2, true, false) &&
25053
2/2
✓ Branch 0 taken 8914 times.
✓ Branch 1 taken 1272 times.
10186 iswaterex_z3(0, -1, x2, y1, true, false) &&
25054 8914 iswaterex_z3(0, -1, x2, y2, true, false)) water = iswaterex_z3(0, -1, (x2+x1)/2,(y2+y1)/2, true, false);
25055 1092995 }
25056 else
25057 {
25058 3141629 types[0] = COMBOTYPE(x1,y1);
25059
2/2
✓ Branch 0 taken 3035678 times.
✓ Branch 1 taken 105951 times.
3141629 if (auto ffc_handle = getFFCAt(x1, y1))
25060 105951 types[0] = ffc_handle->ctype();
25061
25062 3141629 types[1] = COMBOTYPE(x1,y2);
25063
2/2
✓ Branch 0 taken 3049172 times.
✓ Branch 1 taken 92457 times.
3141629 if (auto ffc_handle = getFFCAt(x1, y2))
25064 92457 types[1] = ffc_handle->ctype();
25065
25066 3141629 types[2] = COMBOTYPE(x2,y1);
25067
2/2
✓ Branch 0 taken 3033811 times.
✓ Branch 1 taken 107818 times.
3141629 if (auto ffc_handle = getFFCAt(x2, y1))
25068 107818 types[2] = ffc_handle->ctype();
25069
25070 3141629 types[3] = COMBOTYPE(x2,y2);
25071
2/2
✓ Branch 0 taken 3045561 times.
✓ Branch 1 taken 96068 times.
3141629 if (auto ffc_handle = getFFCAt(x2, y2))
25072 96068 types[3] = ffc_handle->ctype();
25073
25074 3141629 int32_t typec = COMBOTYPE((x2+x1)/2,(y2+y1)/2);
25075
2/2
✓ Branch 0 taken 101346 times.
✓ Branch 1 taken 3040283 times.
3141629 if(MAPFFCOMBO((x2+x1)/2,(y2+y1)/2))
25076 101346 typec = FFCOMBOTYPE((x2+x1)/2,(y2+y1)/2);
25077
25078
5/6
✓ Branch 0 taken 9045 times.
✓ Branch 1 taken 3132584 times.
✓ Branch 2 taken 8649 times.
✓ Branch 3 taken 396 times.
✓ Branch 4 taken 8168 times.
✗ Branch 5 not taken.
3149797 if(combo_class_buf[types[0]].water && combo_class_buf[types[1]].water &&
25079
3/4
✓ Branch 0 taken 8168 times.
✓ Branch 1 taken 481 times.
✓ Branch 2 taken 8168 times.
✗ Branch 3 not taken.
8649 combo_class_buf[types[2]].water && combo_class_buf[types[3]].water && combo_class_buf[typec].water)
25080 8168 water = typec;
25081 }
25082 4234624 }
25083
25084 // Pits (aka direct warps) have a bigger 'hitbox' than stairs...
25085 6857360 x1 = tx+7;
25086 6857360 x2 = tx+8;
25087 6857360 y1 = ty+7+(bigHitbox?0:4);
25088 6857360 y2 = ty+8+(bigHitbox?0:4);
25089
25090 6857360 rpos_handles[0] = get_rpos_handle_for_world_xy(x1, y1, 0);
25091 6857360 rpos_handles[1] = get_rpos_handle_for_world_xy(x1, y2, 0);
25092 6857360 rpos_handles[2] = get_rpos_handle_for_world_xy(x2, y1, 0);
25093 6857360 rpos_handles[3] = get_rpos_handle_for_world_xy(x2, y2, 0);
25094
25095 6857360 cids[0] = rpos_handles[0].data();
25096 6857360 cids[1] = rpos_handles[1].data();
25097 6857360 cids[2] = rpos_handles[2].data();
25098 6857360 cids[3] = rpos_handles[3].data();
25099
25100 6857360 types[0] = rpos_handles[0].ctype();
25101 6857360 scrs[0] = rpos_handles[0].scr;
25102
2/2
✓ Branch 0 taken 6726288 times.
✓ Branch 1 taken 131072 times.
6857360 if (auto ffc_handle = getFFCAt(x1, y1))
25103 {
25104 131072 types[0] = ffc_handle->ctype();
25105 131072 cids[0] = ffc_handle->data();
25106 131072 scrs[0] = ffc_handle->scr;
25107 131072 }
25108
25109 6857360 types[1] = rpos_handles[1].ctype();
25110 6857360 scrs[1] = rpos_handles[1].scr;
25111
2/2
✓ Branch 0 taken 6727327 times.
✓ Branch 1 taken 130033 times.
6857360 if (auto ffc_handle = getFFCAt(x1, y2))
25112 {
25113 130033 types[1] = ffc_handle->ctype();
25114 130033 cids[1] = ffc_handle->data();
25115 130033 scrs[1] = ffc_handle->scr;
25116 130033 }
25117
25118 6857360 types[2] = rpos_handles[2].ctype();
25119 6857360 scrs[2] = rpos_handles[2].scr;
25120
2/2
✓ Branch 0 taken 6725619 times.
✓ Branch 1 taken 131741 times.
6857360 if (auto ffc_handle = getFFCAt(x2, y1))
25121 {
25122 131741 types[2] = ffc_handle->ctype();
25123 131741 cids[2] = ffc_handle->data();
25124 131741 scrs[2] = ffc_handle->scr;
25125 131741 }
25126
25127 6857360 types[3] = rpos_handles[3].ctype();
25128 6857360 scrs[3] = rpos_handles[3].scr;
25129
2/2
✓ Branch 0 taken 6726626 times.
✓ Branch 1 taken 130734 times.
6857360 if (auto ffc_handle = getFFCAt(x2, y2))
25130 {
25131 130734 types[3] = ffc_handle->ctype();
25132 130734 cids[3] = ffc_handle->data();
25133 130734 scrs[3] = ffc_handle->scr;
25134 130734 }
25135
25136
2/2
✓ Branch 0 taken 27441056 times.
✓ Branch 1 taken 6857360 times.
34298416 for(int32_t i=0; i<4; i++)
25137 {
25138
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 27440792 times.
27441056 if(combobuf[cids[i]].only_gentrig)
25139 {
25140 264 types[i] = cNONE;
25141 264 continue;
25142 }
25143
2/2
✓ Branch 0 taken 3037 times.
✓ Branch 1 taken 27437755 times.
27440792 if(types[i]==cPIT)
25144 {
25145 3037 index=0;
25146 3037 warpsfx2 = combobuf[cids[i]].attribytes[0];
25147 3037 }
25148
2/2
✓ Branch 0 taken 5004 times.
✓ Branch 1 taken 27432751 times.
27437755 else if(types[i]==cPITB)
25149 {
25150 5004 types[i]=cPIT;
25151 5004 index=1;
25152 5004 warpsfx2 = combobuf[cids[i]].attribytes[0];
25153 5004 }
25154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27432751 times.
27432751 else if(types[i]==cPITC)
25155 {
25156 types[i]=cPIT;
25157 index=2;
25158 warpsfx2 = combobuf[cids[i]].attribytes[0];
25159 }
25160
2/2
✓ Branch 0 taken 27432749 times.
✓ Branch 1 taken 2 times.
27432751 else if(types[i]==cPITD)
25161 {
25162 2 types[i]=cPIT;
25163 2 index=3;
25164 2 warpsfx2 = combobuf[cids[i]].attribytes[0];
25165 2 }
25166 27440792 }
25167
25168
8/8
✓ Branch 0 taken 6858259 times.
✓ Branch 1 taken 2255 times.
✓ Branch 2 taken 6858241 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 6858043 times.
✓ Branch 5 taken 198 times.
✓ Branch 6 taken 1778 times.
✓ Branch 7 taken 6856265 times.
6857360 if(types[0]==cPIT||types[1]==cPIT||types[2]==cPIT||types[3]==cPIT)
25169
3/8
✓ Branch 0 taken 2221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2221 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2221 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6470 if(action!=freeze&&action!=sideswimfreeze&& (!msg_active || !get_qr(qr_MSGFREEZE)))
25170 2221 type = cPIT;
25171
25172 //
25173 // Time to act on our results for type, flag, flag2 and flag3...
25174 //
25175
3/4
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 6858257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 229 times.
6858486 if(type==cSAVE&&cur_screen<128)
25176 229 *ls=1;
25177
25178
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6858486 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6858486 if(type==cSAVE2&&cur_screen<128)
25179 *ls=2;
25180
25181
8/8
✓ Branch 0 taken 6849914 times.
✓ Branch 1 taken 8572 times.
✓ Branch 2 taken 6833499 times.
✓ Branch 3 taken 16415 times.
✓ Branch 4 taken 6832969 times.
✓ Branch 5 taken 530 times.
✓ Branch 6 taken 13806 times.
✓ Branch 7 taken 6846775 times.
6858486 if(refilling==REFILL_LIFE || flag==mfFAIRY||flag2==mfFAIRY||flag3==mfFAIRY)
25182 {
25183 39323 fairycircle(REFILL_LIFE);
25184
25185
2/2
✓ Branch 0 taken 34991 times.
✓ Branch 1 taken 4332 times.
39323 if(fairyclk!=0) return;
25186 4332 }
25187
25188
7/8
✓ Branch 0 taken 6837287 times.
✓ Branch 1 taken 13820 times.
✓ Branch 2 taken 6837205 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 6837205 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13834 times.
✓ Branch 7 taken 6851039 times.
6851107 if(refilling==REFILL_MAGIC || flag==mfMAGICFAIRY||flag2==mfMAGICFAIRY||flag3==mfMAGICFAIRY)
25189 {
25190 27736 fairycircle(REFILL_MAGIC);
25191
25192
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1 times.
27736 if(fairyclk!=0) return;
25193 1 }
25194
25195
7/8
✓ Branch 0 taken 6837172 times.
✓ Branch 1 taken 13868 times.
✓ Branch 2 taken 6836991 times.
✓ Branch 3 taken 181 times.
✓ Branch 4 taken 6836991 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13902 times.
✓ Branch 7 taken 6850893 times.
6851040 if(refilling==REFILL_ALL || flag==mfALLFAIRY||flag2==mfALLFAIRY||flag3==mfALLFAIRY)
25196 {
25197 27951 fairycircle(REFILL_ALL);
25198
25199
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 19 times.
27951 if(fairyclk!=0) return;
25200 19 }
25201
25202 // Just in case Hero was moved off of the fairy flag
25203
1/2
✓ Branch 0 taken 6850912 times.
✗ Branch 1 not taken.
6850912 if(refilling==REFILL_FAIRYDONE)
25204 {
25205 fairycircle(REFILL_NONE);
25206
25207 if(fairyclk!=0) return;
25208 }
25209
25210
6/8
✓ Branch 0 taken 6837000 times.
✓ Branch 1 taken 13912 times.
✓ Branch 2 taken 6837000 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6837000 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13922 times.
✓ Branch 7 taken 6850786 times.
6850912 if(flag==mfZELDA||flag2==mfZELDA||flag3==mfZELDA || combo_class_buf[type].win_game)
25211 {
25212 27834 attackclk = 0; //get rid of Hero's sword if it was stuck out, charged.
25213 27834 win_game();
25214 27834 return;
25215 }
25216
25217
4/4
✓ Branch 0 taken 6818144 times.
✓ Branch 1 taken 32642 times.
✓ Branch 2 taken 6832210 times.
✓ Branch 3 taken 18576 times.
6850786 if((z>0 || fakez>0) && !(hero_scr->flags2&fAIRCOMBOS))
25218 18576 return;
25219
25220
4/4
✓ Branch 0 taken 6815793 times.
✓ Branch 1 taken 16417 times.
✓ Branch 2 taken 723 times.
✓ Branch 3 taken 6815070 times.
6832210 if((type==cTRIGNOFLAG || type==cTRIGFLAG))
25221 {
25222
4/4
✓ Branch 0 taken 2089 times.
✓ Branch 1 taken 15051 times.
✓ Branch 2 taken 15417 times.
✓ Branch 3 taken 16618 times.
17140 if (COMBOPOS_REGION(tx+8, ty+8)!=stepsecret || get_qr(qr_TRIGGERSREPEAT))
25223 {
25224 30468 stepsecret = COMBOPOS_REGION(tx+8, ty+8);
25225 30468 auto rpos_handle = get_rpos_handle(stepsecret, 0);
25226 30468 sfx(combobuf[MAPCOMBO(rpos_handle)].attribytes[0],pan((int32_t)x));
25227
25228
4/4
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 2631 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 200 times.
30468 if(type==cTRIGFLAG && canPermSecret(cur_dmap, rpos_handle.screen))
25229 {
25230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 200 times.
200 if(!(rpos_handle.scr->flags5&fTEMPSECRETS)) setmapflag(rpos_handle.scr, mSECRET);
25231
25232 200 trigger_secrets_for_screen(TriggerSource::Unspecified, rpos_handle.base_scr(), false);
25233 200 }
25234 else
25235 {
25236 2658 bool only16_31 = get_qr(qr_STEPTEMP_SECRET_ONLY_16_31)?true:false;
25237 2658 trigger_secrets_for_screen(TriggerSource::Unspecified, rpos_handle.base_scr(), only16_31);
25238 }
25239 2858 }
25240 19476 }
25241
2/2
✓ Branch 0 taken 1415 times.
✓ Branch 1 taken 6813655 times.
6815070 else if(!didstrig)
25242 {
25243 6813655 stepsecret = rpos_t::None;
25244 6813655 }
25245
25246 //Better? Dock collision
25247
25248 // Drown if:
25249 // * Water (obviously walkable),
25250 // * Quest Rule allows it,
25251 // * Not on stepladder,
25252 // * Not jumping,
25253 // * Not hovering,
25254 // * Not rafting,
25255 // * Not swallowed,
25256 // * Not a dried lake.
25257
25258 // This used to check for swimming too, but I moved that into the block so that you can drown in higher-leveled water. -Dimi
25259
9/12
✓ Branch 0 taken 16844 times.
✓ Branch 1 taken 6780190 times.
✓ Branch 2 taken 16261 times.
✓ Branch 3 taken 583 times.
✓ Branch 4 taken 16261 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10695 times.
✓ Branch 7 taken 5566 times.
✓ Branch 8 taken 10695 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 10695 times.
6844713 if(water > 0 && !ladderx && hoverclk==0 && action!=rafting && !inlikelike && !DRIEDLAKE
25260
4/8
✓ Branch 0 taken 10695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10695 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10695 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10695 times.
✗ Branch 7 not taken.
10695 && ((get_qr(qr_DROWN) && z==0 && fakez==0 && fall>=0 && fakefall>=0) || CanSideSwim())
25261
4/4
✓ Branch 0 taken 10695 times.
✓ Branch 1 taken 10695 times.
✓ Branch 2 taken 10695 times.
✓ Branch 3 taken 10695 times.
10695 && (sideview_mode() || !platform_ffc))
25262 {
25263
8/10
✓ Branch 0 taken 10695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10504 times.
✓ Branch 3 taken 191 times.
✓ Branch 4 taken 10501 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2518 times.
✓ Branch 7 taken 7983 times.
✓ Branch 8 taken 2518 times.
✗ Branch 9 not taken.
10695 if(!is_autowalking() && (current_item(itype_flippers) <= 0 || current_item(itype_flippers) < combobuf[water].attribytes[0] || ((combobuf[water].usrflags&cflag1) && !(itemsbuf[current_item_id(itype_flippers)].flags & item_flag3))))
25264 {
25265
1/2
✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
194 if(!(ladderx+laddery)) drownCombo = water;
25266
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 190 times.
194 if (combobuf[water].usrflags&cflag1) Drown(1);
25267 190 else Drown();
25268
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 16 times.
194 if(byte drown_sfx = combobuf[water].attribytes[4])
25269 16 sfx(drown_sfx, pan(x));
25270 194 }
25271
2/2
✓ Branch 0 taken 10237 times.
✓ Branch 1 taken 264 times.
10501 else if (!isSwimming())
25272 {
25273 264 SetSwim();
25274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 264 times.
264 if (!IsSideSwim()) attackclk = charging = spins = 0;
25275 264 landswim=0;
25276 264 return;
25277 }
25278 10431 }
25279
25280
25281
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 6817826 times.
6818160 if(type==cSTEP)
25282 {
25283 334 rpos_t next_step = COMBOPOS_REGION(tx+8, ty+8);
25284
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 186 times.
334 if (next_step != stepnext)
25285 {
25286 186 stepnext = next_step;
25287 186 auto rpos_handle = get_rpos_handle(stepnext, 0);
25288 186 int cid = MAPCOMBO(rpos_handle);
25289
25290 if
25291 (
25292
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 19 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEP && /*required item*/
25293
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167 (!combobuf[cid].attribytes[1] || (combobuf[cid].attribytes[1] && game->item[combobuf[cid].attribytes[1]]) )
25294 && /*HEAVY*/
25295
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 167 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
167 ( ( !(combobuf[cid].usrflags&cflag1) ) || ((combobuf[cid].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
25296 )
25297 {
25298 167 sfx(combobuf[cid].attribytes[0],pan((int32_t)x));
25299 167 rpos_handle.increment_data();
25300 167 }
25301
25302 if
25303 (
25304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 186 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEPSAME && /*required item*/
25305 (!combobuf[cid].attribytes[1] || (combobuf[cid].attribytes[1] && game->item[combobuf[cid].attribytes[1]]) )
25306 && /*HEAVY*/
25307 ( ( !(combobuf[cid].usrflags&cflag1) ) || ((combobuf[cid].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
25308 )
25309 {
25310 sfx(combobuf[cid].attribytes[0],pan((int32_t)x));
25311 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
25312 if (rpos_handle.data() == cid)
25313 rpos_handle.increment_data();
25314 });
25315 }
25316
25317 if
25318 (
25319
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 179 times.
186 COMBOTYPE(tx+8,ty+8)==cSTEPALL && /*required item*/
25320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 (!combobuf[MAPCOMBO(tx+8,ty+8)].attribytes[1] || (combobuf[cid].attribytes[1] && game->item[combobuf[cid].attribytes[1]]) )
25321 && /*HEAVY*/
25322
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 ( ( !(combobuf[cid].usrflags&cflag1) ) || ((combobuf[cid].usrflags&cflag1) && Hero.HasHeavyBoots() ) )
25323 )
25324 {
25325 7 sfx(combobuf[cid].attribytes[0],pan((int32_t)x));
25326
25327 1239 for_every_rpos([&](const rpos_handle_t& rpos_handle) {
25328
2/2
✓ Branch 0 taken 1051 times.
✓ Branch 1 taken 181 times.
1232 if (isStepType(rpos_handle.ctype()))
25329 181 rpos_handle.increment_data();
25330 1232 });
25331 7 }
25332 186 }
25333 334 }
25334
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6817826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6817826 else if(type==cSTEPSFX && action == walking)
25335 {
25336 trigger_stepfx(get_rpos_handle_for_world_xy(tx + 8, ty + 8, 0), true);
25337 }
25338 6817826 else stepnext = rpos_t::None;
25339
25340 6818160 detail_int[0]=tx;
25341 6818160 detail_int[1]=ty;
25342
25343
25344
8/8
✓ Branch 0 taken 6817702 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 881 times.
✓ Branch 3 taken 6817279 times.
✓ Branch 4 taken 6815293 times.
✓ Branch 5 taken 1986 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 11 times.
6818185 if(!((type==cCAVE || type==cCAVE2) && z==0 && fakez==0) && type!=cSTAIR &&
25345
5/6
✓ Branch 0 taken 6814341 times.
✓ Branch 1 taken 952 times.
✓ Branch 2 taken 6814320 times.
✓ Branch 3 taken 21 times.
✓ Branch 4 taken 6814320 times.
✗ Branch 5 not taken.
6815293 type!=cPIT && type!=cSWIMWARP && type!=cRESET &&
25346
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 6814295 times.
6814320 !(type==cDIVEWARP && isDiving()))
25347 6814306 {
25348 RaftingStuff:
25349
2/2
✓ Branch 0 taken 6813747 times.
✓ Branch 1 taken 559 times.
6814306 if (get_qr(qr_BETTER_RAFT_2))
25350 {
25351 559 bool doraft = true;
25352
4/6
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 556 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
559 if(((int32_t)y>=raftwarpy-12&&(int32_t)y<=raftwarpy+3)&&raftwarpy!=-1)
25353 {
25354
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
3 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25355 {
25356 3 doraft = false;
25357 3 }
25358 3 }
25359 //if (mfRAFT)
25360 int32_t rafttypes[2];
25361 559 int32_t raftx1 = tx+6;
25362 559 int32_t raftx2 = tx+9;
25363 559 int32_t rafty = ty+11;
25364 int32_t raftflags[3];
25365 559 rafttypes[0]=rafttypes[1]=-1;
25366 559 raftflags[0]=raftflags[1]=raftflags[2]=0;
25367 559 rafttypes[0] = MAPFLAG(raftx1,rafty);
25368 559 rafttypes[1] = MAPFLAG(raftx2,rafty);
25369
25370
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
25371 559 raftflags[0] = rafttypes[0];
25372
25373
25374 559 rafttypes[0] = MAPCOMBOFLAG(raftx1,rafty);
25375 559 rafttypes[1] = MAPCOMBOFLAG(raftx2,rafty);
25376
25377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
25378 559 raftflags[1] = rafttypes[0];
25379
25380 559 rafttypes[0] = MAPFFCOMBOFLAG(raftx1,rafty);
25381 559 rafttypes[1] = MAPFFCOMBOFLAG(raftx2,rafty);
25382
25383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(rafttypes[0]==rafttypes[1])
25384 559 raftflags[2] = rafttypes[0];
25385
25386
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 559 times.
2236 for (int32_t m = 0; m < 3; ++m)
25387 {
25388
2/4
✓ Branch 0 taken 1677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1677 times.
1677 if (raftflags[m] == mfRAFT || raftflags[m] == mfRAFT_BRANCH)
25389 {
25390 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && (combo_class_buf[COMBOTYPE(tx+8, ty+11)].dock || combo_class_buf[FFCOMBOTYPE(tx+8, ty+11)].dock))
25391 {
25392 if((isRaftFlag(nextflag(tx,ty+11,dir,false))||isRaftFlag(nextflag(tx,ty+11,dir,true))))
25393 {
25394 reset_swordcharge();
25395 action=rafting; FFCore.setHeroAction(rafting);
25396 raftclk=0;
25397 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x));
25398 else sfx(get_scr_for_world_xy(tx,ty+11)->secretsfx);
25399 }
25400 else if (get_qr(qr_BETTER_RAFT) && doraft)
25401 {
25402 for (int32_t i = 0; i < 4; ++i)
25403 {
25404 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+11),i,true)))
25405 {
25406 reset_swordcharge();
25407 action=rafting; FFCore.setHeroAction(rafting);
25408 raftclk=0;
25409 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x));
25410 else sfx(get_scr_for_world_xy(tx+8,ty+11)->secretsfx);
25411 dir = i;
25412 break;
25413 }
25414 }
25415 }
25416 }
25417 }
25418 1677 }
25419 559 }
25420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6814306 times.
6814306 if (RaftPass) return;
25421
3/3
✓ Branch 0 taken 34031 times.
✓ Branch 1 taken 6779215 times.
✓ Branch 2 taken 1060 times.
6814306 switch(flag)
25422 {
25423 case mfDIVE_ITEM:
25424
6/8
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 1036 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 15 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
1060 if(isDiving() && (!getmapflag(flag_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (flag_scr->flags9&fBELOWRETURN)))
25425 {
25426 30 additem(x, y, flag_scr->catchall,
25427 15 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((flag_scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25428 15 sfx(flag_scr->secretsfx);
25429 15 }
25430
25431 1060 return;
25432
25433 case mfRAFT:
25434 case mfRAFT_BRANCH:
25435
25436 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25437
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34031 times.
34031 if (!get_qr(qr_BETTER_RAFT_2))
25438 {
25439 34031 bool doraft = true;
25440
5/6
✓ Branch 0 taken 34031 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2122 times.
✓ Branch 3 taken 31909 times.
✓ Branch 4 taken 1546 times.
✓ Branch 5 taken 576 times.
34031 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25441 {
25442
5/6
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 808 times.
✓ Branch 3 taken 738 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 785 times.
1546 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25443 {
25444 785 doraft = false;
25445 785 }
25446 1546 }
25447
13/16
✓ Branch 0 taken 31056 times.
✓ Branch 1 taken 2975 times.
✓ Branch 2 taken 3282 times.
✓ Branch 3 taken 27774 times.
✓ Branch 4 taken 3262 times.
✓ Branch 5 taken 20 times.
✓ Branch 6 taken 3251 times.
✓ Branch 7 taken 11 times.
✓ Branch 8 taken 3251 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3251 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3251 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1531 times.
✓ Branch 15 taken 1720 times.
34031 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25448 {
25449
3/4
✓ Branch 0 taken 1365 times.
✓ Branch 1 taken 355 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1365 times.
1720 if(isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true)))
25450 {
25451 355 reset_swordcharge();
25452 355 action=rafting; FFCore.setHeroAction(rafting);
25453 355 raftclk=0;
25454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 355 times.
355 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x));
25455 355 else sfx(get_scr_for_world_xy(tx,ty)->secretsfx);
25456 355 }
25457
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1365 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1365 else if (get_qr(qr_BETTER_RAFT) && doraft)
25458 {
25459 for (int32_t i = 0; i < 4; ++i)
25460 {
25461 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25462 {
25463 reset_swordcharge();
25464 action=rafting; FFCore.setHeroAction(rafting);
25465 raftclk=0;
25466 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x));
25467 else sfx(get_scr_for_world_xy(tx+8,ty+8)->secretsfx);
25468 dir = i;
25469 break;
25470 }
25471 }
25472 }
25473 1720 }
25474 34031 }
25475
25476 34031 return;
25477
25478 default:
25479 6779215 break;
25480 //return;
25481 }
25482
25483
2/3
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 6778941 times.
✗ Branch 2 not taken.
6779215 switch(flag2)
25484 {
25485 case mfDIVE_ITEM:
25486 if(isDiving() && (!getmapflag(flag2_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (flag2_scr->flags9&fBELOWRETURN)))
25487 {
25488 additem(x, y, flag2_scr->catchall,
25489 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((flag2_scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25490 sfx(flag2_scr->secretsfx);
25491 }
25492
25493 return;
25494
25495 case mfRAFT:
25496 case mfRAFT_BRANCH:
25497
25498 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if (!get_qr(qr_BETTER_RAFT_2))
25500 {
25501 274 bool doraft = true;
25502
2/6
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 274 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
274 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25503 {
25504 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25505 {
25506 doraft = false;
25507 }
25508 }
25509
10/16
✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 135 times.
✓ Branch 3 taken 139 times.
✓ Branch 4 taken 135 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 135 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 135 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 135 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 135 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 121 times.
✓ Branch 15 taken 14 times.
274 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25510 {
25511
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 9 times.
14 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
25512 {
25513 5 reset_swordcharge();
25514 5 action=rafting; FFCore.setHeroAction(rafting);
25515 5 raftclk=0;
25516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x));
25517 5 else sfx(get_scr_for_world_xy(tx,ty)->secretsfx);
25518 5 }
25519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9 else if (get_qr(qr_BETTER_RAFT) && doraft)
25520 {
25521 for (int32_t i = 0; i < 4; ++i)
25522 {
25523 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25524 {
25525 reset_swordcharge();
25526 action=rafting; FFCore.setHeroAction(rafting);
25527 raftclk=0;
25528 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x));
25529 else sfx(get_scr_for_world_xy(tx+8,ty+8)->secretsfx);
25530 dir = i;
25531 break;
25532 }
25533 }
25534 }
25535 14 }
25536 274 }
25537
25538 274 return;
25539
25540 default:
25541 6778941 break;
25542 //return;
25543 }
25544
25545
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 6778941 times.
✗ Branch 2 not taken.
6778941 switch(flag3)
25546 {
25547 case mfDIVE_ITEM:
25548 if(isDiving() && (!getmapflag(flag3_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (flag3_scr->flags9&fBELOWRETURN)))
25549 {
25550 additem(x, y, flag3_scr->catchall,
25551 ipONETIME2 | ipBIGRANGE | ipHOLDUP | ipNODRAW | ((flag3_scr->flags8&fITEMSECRET) ? ipSECRETS : 0));
25552 sfx(flag3_scr->secretsfx);
25553 }
25554
25555 return;
25556
25557 case mfRAFT:
25558 case mfRAFT_BRANCH:
25559
25560 // if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && type==cOLD_DOCK)
25561 if (!get_qr(qr_BETTER_RAFT_2))
25562 {
25563 bool doraft = true;
25564 if(((int32_t)y>=raftwarpy-8&&(int32_t)y<=raftwarpy+7)&&raftwarpy!=-1)
25565 {
25566 if(((int32_t)x>=raftwarpx-8&&(int32_t)x<=raftwarpx+7)&&raftwarpx!=-1)
25567 {
25568 doraft = false;
25569 }
25570 }
25571 if(current_item(itype_raft) && action!=rafting && action!=swimhit && action!=gothit && action!=sideswimhit && z==0 && fakez==0 && combo_class_buf[type].dock)
25572 {
25573 if((isRaftFlag(nextflag(tx,ty,dir,false))||isRaftFlag(nextflag(tx,ty,dir,true))))
25574 {
25575 reset_swordcharge();
25576 action=rafting; FFCore.setHeroAction(rafting);
25577 raftclk=0;
25578 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x));
25579 else sfx(get_scr_for_world_xy(tx,ty)->secretsfx);
25580 }
25581 else if (get_qr(qr_BETTER_RAFT) && doraft)
25582 {
25583 for (int32_t i = 0; i < 4; ++i)
25584 {
25585 if(isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,false))||isRaftFlag(nextflag(GridX(tx+8),GridY(ty+8),i,true)))
25586 {
25587 reset_swordcharge();
25588 action=rafting; FFCore.setHeroAction(rafting);
25589 raftclk=0;
25590 if (get_qr(qr_RAFT_SOUND)) sfx(itemsbuf[current_item_id(itype_raft)].usesound,pan(x));
25591 else sfx(get_scr_for_world_xy(tx+8,ty+8)->secretsfx);
25592 dir = i;
25593 break;
25594 }
25595 }
25596 }
25597 }
25598 }
25599
25600 return;
25601
25602 default:
25603 6778941 return;
25604 }
25605 }
25606
25607 // Either the screen the hero is currently in, or if in a 0x80 room the screen player came from.
25608
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 3797 times.
3854 mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : hero_scr;
25609
25610
3/4
✓ Branch 0 taken 3396 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 3854 times.
✗ Branch 3 not taken.
3854 if((type==cCAVE || type==cCAVE2) && (base_scr->tilewarptype[index]==wtNOWARP)) return;
25611
25612 3854 bool skippedaframe=false;
25613
25614
6/6
✓ Branch 0 taken 3396 times.
✓ Branch 1 taken 458 times.
✓ Branch 2 taken 2973 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 1986 times.
✓ Branch 5 taken 987 times.
3854 if(type==cCAVE || type==cCAVE2 || type==cSTAIR)
25615 {
25616 // Stop music only if:
25617 // * entering a Guy Cave
25618 // * warping to a DMap whose music is different.
25619
25620 2867 int32_t tdm = base_scr->tilewarpdmap[index];
25621
25622
2/2
✓ Branch 0 taken 957 times.
✓ Branch 1 taken 1910 times.
2867 if(base_scr->tilewarptype[index]<=wtPASS)
25623 {
25624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 957 times.
957 if (FFCore.can_dmap_change_music(tdm))
25625 {
25626
3/4
✓ Branch 0 taken 488 times.
✓ Branch 1 taken 469 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
957 if ((DMaps[cur_dmap].flags & dmfCAVES) && base_scr->tilewarptype[index] == wtCAVE)
25627 488 music_stop();
25628 957 }
25629 957 }
25630 else
25631 {
25632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910 times.
1910 if (FFCore.can_dmap_change_music(tdm))
25633 {
25634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1910 times.
1910 if (zcmusic != NULL)
25635 {
25636 if (strcmp(zcmusic->filename, DMaps[tdm].tmusic) != 0 ||
25637 (zcmusic->type == ZCMF_GME && zcmusic->track != DMaps[tdm].tmusictrack))
25638 music_stop();
25639 }
25640
2/4
✓ Branch 0 taken 1910 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1910 times.
1910 else if (DMaps[hero_scr->tilewarpdmap[index]].midi != (currmidi - ZC_MIDI_COUNT + 4) &&
25641 1910 get_canonical_scr(DMaps[tdm].map, base_scr->tilewarpscr[index] + DMaps[tdm].xoff)->screen_midi != (currmidi - ZC_MIDI_COUNT + 4))
25642 1910 music_stop();
25643 1910 }
25644 }
25645
25646 2867 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
25647
5/6
✓ Branch 0 taken 957 times.
✓ Branch 1 taken 1910 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 469 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 488 times.
2867 bool opening = (base_scr->tilewarptype[index]<=wtPASS && !(DMaps[cur_dmap].flags&dmfCAVES && base_scr->tilewarptype[index]==wtCAVE)
25648 2398 ? false : COOLSCROLL);
25649
25650 2867 FFCore.warpScriptCheck();
25651 2867 draw_screen();
25652 2867 advanceframe(true);
25653
25654 2867 skippedaframe=true;
25655
25656
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 2444 times.
2867 if(type==cCAVE2) walkup2(opening);
25657
2/2
✓ Branch 0 taken 1986 times.
✓ Branch 1 taken 458 times.
2444 else if(type==cCAVE) walkdown(opening);
25658 2867 }
25659
25660
2/2
✓ Branch 0 taken 2902 times.
✓ Branch 1 taken 952 times.
3854 if(type==cPIT)
25661 {
25662 952 setpit();
25663 952 warp_sound = warpsfx2;
25664 952 }
25665
25666 3854 mapscr* scr = nullptr;
25667
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7708 times.
✓ Branch 2 taken 3854 times.
✓ Branch 3 taken 3854 times.
7708 for (int i = 0; i < 4 && !scr; i++) scr = scrs[i];
25668
1/2
✓ Branch 0 taken 3854 times.
✗ Branch 1 not taken.
3854 if (!scr) scr = hero_scr;
25669
25670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
3911 if (!is_in_scrolling_region()
25671
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 2 times.
3854 && DMaps[cur_dmap].flags&dmf3STAIR
25672
4/4
✓ Branch 0 taken 1293 times.
✓ Branch 1 taken 2559 times.
✓ Branch 2 taken 1236 times.
✓ Branch 3 taken 57 times.
3852 && (cur_screen==129 || !(DMaps[cur_dmap].flags&dmfGUYCAVES))
25673
7/8
✓ Branch 0 taken 1079 times.
✓ Branch 1 taken 157 times.
✓ Branch 2 taken 57 times.
✓ Branch 3 taken 157 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 57 times.
✓ Branch 6 taken 57 times.
✓ Branch 7 taken 157 times.
1293 && (specialcave > 0 && DMaps[cur_dmap].flags & dmfGUYCAVES ? special_warp_return_scr : scr)->room==rWARP && type==cSTAIR)
25674 {
25675
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(!skippedaframe)
25676 {
25677 FFCore.warpScriptCheck();
25678 draw_screen();
25679 advanceframe(true);
25680 }
25681
25682 // "take any road you want"
25683
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 11 times.
57 int32_t dw = x<112 ? 1 : (x>136 ? 3 : 2);
25684 57 int32_t code = WARPCODE(cur_dmap,home_screen,dw);
25685
25686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(code>-1)
25687 {
25688 57 bool changedlevel = false;
25689 57 bool changeddmap = false;
25690
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 15 times.
57 if(cur_dmap != code>>8)
25691 {
25692 15 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
25693 15 changeddmap = true;
25694 15 }
25695
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(dlevel != DMaps[code>>8].level)
25696 {
25697 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
25698 changedlevel = true;
25699 }
25700 57 cur_dmap = code>>8;
25701 57 dlevel = DMaps[cur_dmap].level;
25702
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 15 times.
57 if(changeddmap)
25703 {
25704 15 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
25705 15 }
25706
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(changedlevel)
25707 {
25708 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
25709 }
25710
25711 57 cur_map = DMaps[cur_dmap].map;
25712 57 home_screen = (code&0xFF) + DMaps[cur_dmap].xoff;
25713 57 init_dmap();
25714
25715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(canPermSecret(cur_dmap, cur_screen))
25716 57 setmapflag_homescr(mSECRET);
25717 57 }
25718
25719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
57 if(specialcave==STAIRCAVE) exitcave();
25720
25721 57 return;
25722 }
25723
25724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3797 times.
3797 if(type==cRESET)
25725 {
25726 if(!skippedaframe)
25727 {
25728 FFCore.warpScriptCheck();
25729 draw_screen();
25730 advanceframe(true);
25731 }
25732
25733 for(auto flag : {mSECRET,mITEM,mSPECIALITEM,mNEVERRET,mCHEST,mLOCKEDCHEST,mBOSSCHEST,
25734 mLOCKBLOCK,mBOSSLOCKBLOCK,mTMPNORET,mVISITED,mLIGHTBEAM,mNO_ENEMIES_RETURN})
25735 {
25736 if(!(scr->noreset&flag))
25737 unsetmapflag(scr, flag);
25738 }
25739
25740 if(isdungeon())
25741 {
25742 for(auto flag : {mDOOR_LEFT,mDOOR_RIGHT,mDOOR_DOWN,mDOOR_UP})
25743 {
25744 if(!(scr->noreset&flag))
25745 unsetmapflag(scr, flag);
25746 }
25747 }
25748
25749 if(scr->exstate_reset)
25750 {
25751 for(uint q = 0; q < 32; ++q)
25752 if(scr->exstate_reset&(1<<q))
25753 unsetxmapflag(scr->screen, (1<<q));
25754 }
25755
25756 setpit();
25757 sdir=dir;
25758 dowarp(scr, 4, 0, warpsfx2);
25759 }
25760 else
25761 {
25762
3/4
✓ Branch 0 taken 987 times.
✓ Branch 1 taken 2810 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 987 times.
3797 if(!skippedaframe && (base_scr->tilewarptype[index]!=wtNOWARP))
25763 {
25764 987 FFCore.warpScriptCheck();
25765 987 draw_screen();
25766 987 advanceframe(true);
25767 987 }
25768
25769 3797 sdir = dir;
25770 3797 dowarp(scr, 0, index, warpsfx2);
25771 }
25772 14247886 }
25773
25774 126 int32_t selectWlevel(int32_t d)
25775 {
25776
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if(TriforceCount()==0)
25777 return 0;
25778
25779 126 word l = game->get_wlevel();
25780
25781 126 do
25782 {
25783
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 199 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
199 if(d==0 && (game->lvlitems[l+1] & liTRIFORCE))
25784 break;
25785
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 80 times.
199 else if(d<0)
25786
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 16 times.
80 l = (l==0) ? 7 : l-1;
25787 else
25788
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 103 times.
119 l = (l==7) ? 0 : l+1;
25789
2/2
✓ Branch 0 taken 73 times.
✓ Branch 1 taken 126 times.
199 }
25790 199 while(!(game->lvlitems[l+1] & liTRIFORCE));
25791
25792 126 game->set_wlevel(l);
25793 126 return l;
25794 126 }
25795
25796 // Would someone tell the Dodongos to shut their yaps?!
25797 27954 void kill_enemy_sfx()
25798 {
25799
2/2
✓ Branch 0 taken 27954 times.
✓ Branch 1 taken 55326 times.
83280 for(int32_t i=0; i<guys.Count(); i++)
25800 {
25801
2/2
✓ Branch 0 taken 20640 times.
✓ Branch 1 taken 34686 times.
55326 if(((enemy*)guys.spr(i))->bgsfx)
25802 34686 stop_sfx(((enemy*)guys.spr(i))->bgsfx);
25803 55326 }
25804
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 27829 times.
27954 if (Hero.action!=inwind) stop_sfx(WAV_ZN1WHIRLWIND);
25805
2/2
✓ Branch 0 taken 27938 times.
✓ Branch 1 taken 16 times.
27954 if(hero_scr->room==rGANON)
25806 16 stop_sfx(WAV_ROAR);
25807 27954 }
25808
25809 3271 bool HeroClass::HasHeavyBoots()
25810 {
25811
2/2
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 837376 times.
840647 for ( int32_t q = 0; q < MAXITEMS; ++q )
25812 {
25813
3/6
✓ Branch 0 taken 68711 times.
✓ Branch 1 taken 768665 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68711 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
837376 if ( game->item[q] && ( itemsbuf[q].type == itype_boots ) && /*iron*/ (itemsbuf[q].flags&item_flag2) ) return true;
25814 837376 }
25815 3271 return false;
25816 3271 }
25817
25818 7348 bool HeroClass::dowarp(const mapscr* scr, int32_t type, int32_t index, int32_t warpsfx)
25819 {
25820
1/2
✓ Branch 0 taken 7348 times.
✗ Branch 1 not taken.
7348 if (!scr) scr = hero_scr;
25821
25822 7348 byte reposition_sword_postwarp = 0;
25823
1/2
✓ Branch 0 taken 7348 times.
✗ Branch 1 not taken.
7348 if (index < 0)
25824 {
25825 return false;
25826 }
25827 7348 finish_auto_walk();
25828 7348 is_warping = true;
25829
2/2
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 7348 times.
8117 for (int32_t q = 0; q < Lwpns.Count(); ++q)
25830 {
25831 769 weapon* swd = NULL;
25832 769 swd = (weapon*)Lwpns.spr(q);
25833
2/2
✓ Branch 0 taken 699 times.
✓ Branch 1 taken 70 times.
769 if (swd->id == (attack == wSword ? wSword : wWand))
25834 {
25835 70 Lwpns.del(q);
25836 70 }
25837 769 }
25838
25839 7348 attackclk = charging = spins = tapping = 0;
25840 7348 attack = none;
25841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7348 times.
7348 if (warp_sound > 0) warpsfx = warp_sound;
25842 7348 warp_sound = 0;
25843 7348 word wdmap = 0;
25844 7348 byte wscr = 0, wtype = 0, t = 0;
25845 7348 bool overlay = false;
25846 7348 t = (cur_screen < 128) ? 0 : 1;
25847 7348 int32_t wrindex = 0;
25848 7348 bool wasSideview = isSideViewGravity(t);
25849
25850 // Either the current screen, or if in a 0x80 room the screen player came from.
25851
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 6956 times.
7348 const mapscr* base_scr = cur_screen >= 128 ? special_warp_return_scr : scr;
25852
25853 // Drawing commands probably shouldn't carry over...
25854
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 6956 times.
7348 if (!get_qr(qr_SCRIPTDRAWSINWARPS))
25855 6956 script_drawing_commands.Clear();
25856
25857
2/2
✓ Branch 0 taken 7287 times.
✓ Branch 1 taken 61 times.
7348 if (replay_version_check(35))
25858 {
25859 // TODO: Would be better to remove a bit later, after fading out the current screen. For now, do this here.
25860 // https://github.com/ZQuestClassic/ZQuestClassic/pull/1017#discussion_r1828880117
25861 61 reset_ladder();
25862 61 }
25863
4/6
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 3841 times.
✓ Branch 2 taken 2990 times.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7348 switch(type)
25864 {
25865 case 0: // tile warp
25866 3841 wtype = base_scr->tilewarptype[index];
25867 3841 wdmap = base_scr->tilewarpdmap[index];
25868 3841 wscr = base_scr->tilewarpscr[index];
25869 3841 overlay = get_bit(&base_scr->tilewarpoverlayflags,index)?1:0;
25870 3841 wrindex=(scr->warpreturnc>>(index*2))&3;
25871 3841 break;
25872
25873 case 1: // side warp
25874 2990 wtype = base_scr->sidewarptype[index];
25875 2990 wdmap = base_scr->sidewarpdmap[index];
25876 2990 wscr = base_scr->sidewarpscr[index];
25877 2990 overlay = get_bit(&base_scr->sidewarpoverlayflags,index)?1:0;
25878 2990 wrindex=(scr->warpreturnc>>(8+(index*2)))&3;
25879 2990 break;
25880
25881 case 2: // whistle warp
25882 {
25883 125 wtype = wtWHISTLE;
25884
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 int32_t wind = whistleitem>-1 ? itemsbuf[whistleitem].misc2 : 8;
25885 125 int32_t level=0;
25886
25887
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(blowcnt==0)
25888 level = selectWlevel(0);
25889 else
25890 {
25891
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 125 times.
251 for(int32_t i=0; i<abs(blowcnt); i++)
25892 126 level = selectWlevel(blowcnt);
25893 }
25894
25895
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
125 if(level > QMisc.warp[wind].size && QMisc.warp[wind].size>0)
25896 {
25897 2 level %= QMisc.warp[wind].size;
25898 2 game->set_wlevel(level);
25899 2 }
25900
25901 125 wdmap = QMisc.warp[wind].dmap[level];
25902 125 wscr = QMisc.warp[wind].scr[level];
25903 }
25904 125 break;
25905
25906 case 3:
25907 wtype = wtIWARP;
25908 wdmap = cheat_goto_dmap;
25909 wscr = cheat_goto_screen;
25910 break;
25911
25912 case 4:
25913 wtype = wtIWARP;
25914 wdmap = cur_dmap;
25915 wscr = home_screen-DMaps[cur_dmap].xoff;
25916 break;
25917 }
25918
25919 7348 bool intradmap = (wdmap == cur_dmap);
25920 7348 int32_t olddmap = cur_dmap;
25921 7348 rehydratelake(type!=wtSCROLL);
25922 7348 bool updatemusic = FFCore.can_dmap_change_music(wdmap);
25923 7348 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
25924 7348 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
25925
25926
7/8
✓ Branch 0 taken 3636 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 585 times.
✓ Branch 3 taken 322 times.
✓ Branch 4 taken 1636 times.
✓ Branch 5 taken 893 times.
✓ Branch 6 taken 125 times.
✓ Branch 7 taken 151 times.
7348 switch(wtype)
25927 {
25928 case wtCAVE:
25929 {
25930 // cave/item room
25931 585 ALLOFF();
25932
25933
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 154 times.
585 if(DMaps[cur_dmap].flags&dmfCAVES) // cave
25934 {
25935
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 431 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
431 if (updatemusic || !musicnocut || !get_qr(qr_SCREEN80_OWN_MUSIC))
25936 431 music_stop();
25937 431 kill_sfx();
25938
25939 431 int destscr = 0x80;
25940
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 369 times.
431 if(scr->room==rWARP)
25941 {
25942 62 destscr=0x81;
25943 62 specialcave = STAIRCAVE;
25944 62 }
25945 369 else specialcave = GUYCAVE;
25946
25947 //lighting(2,dir);
25948 431 lighting(false, true);
25949 431 loadlvlpal(10);
25950
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 366 times.
797 bool b2 = COOLSCROLL&&
25951
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 159 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
366 ((combobuf[MAPCOMBO(x,y-16)].type==cCAVE)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2)||
25952
2/4
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEB)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2B)||
25953
2/4
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVEC)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2C)||
25954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 (combobuf[MAPCOMBO(x,y-16)].type==cCAVED)||(combobuf[MAPCOMBO(x,y-16)].type==cCAVE2D));
25955 431 blackscr(30,b2?false:true);
25956 431 loadscr(wdmap, destscr, up, false);
25957 431 scr = hero_scr;
25958 //preloaded freeform combos
25959 431 ffscript_engine(true);
25960 431 dir=up;
25961 431 x=112;
25962 431 y=160;
25963
1/2
✓ Branch 0 taken 431 times.
✗ Branch 1 not taken.
431 if(didpit)
25964 {
25965 didpit=false;
25966 x=pitx;
25967 y=pity;
25968 }
25969
25970 431 reset_hookshot();
25971
1/2
✓ Branch 0 taken 431 times.
✗ Branch 1 not taken.
431 if(reposition_sword_postwarp)
25972 {
25973 weapon *swd=NULL;
25974 for(int32_t i=0; i<Lwpns.Count(); i++)
25975 {
25976 swd = (weapon*)Lwpns.spr(i);
25977
25978 if(swd->id == (attack==wSword ? wSword : wWand))
25979 {
25980 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
25981 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
25982 positionSword(swd,item_id);
25983 break;
25984 }
25985 }
25986 }
25987 431 stepforward(diagonalMovement?5:6, false);
25988 431 }
25989 else // item room
25990 {
25991 154 specialcave = ITEMCELLAR;
25992 154 kill_sfx();
25993 154 draw_screen(false);
25994
25995 //unless the room is already dark, fade to black
25996
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 153 times.
154 if (!get_qr(qr_NEW_DARKROOM))
25997 {
25998
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
153 if(!darkroom)
25999 {
26000 152 darkroom = true;
26001 152 fade(DMaps[cur_dmap].color,true,false);
26002 152 }
26003 153 }
26004 else
26005 1 fade(DMaps[cur_dmap].color, true, false);
26006
26007 154 blackscr(30,true);
26008
26009 154 bool no_x80_dir = true; // TODO: is this necessary?
26010 154 loadscr(wdmap, 0x80, down, false, no_x80_dir);
26011 154 scr = hero_scr;
26012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( dontdraw < 2 ) { dontdraw=1; }
26013 154 draw_screen(false);
26014 154 fade(0xB,true,true);
26015 154 darkroom = false;
26016 154 dir=down;
26017 154 x=48;
26018 154 y=0;
26019
26020 // is this didpit check necessary?
26021
2/2
✓ Branch 0 taken 153 times.
✓ Branch 1 taken 1 times.
154 if(didpit)
26022 {
26023 1 didpit=false;
26024 1 x=pitx;
26025 1 y=pity;
26026 1 }
26027
26028 154 reset_hookshot();
26029
1/2
✓ Branch 0 taken 154 times.
✗ Branch 1 not taken.
154 if(reposition_sword_postwarp)
26030 {
26031 weapon *swd=NULL;
26032 for(int32_t i=0; i<Lwpns.Count(); i++)
26033 {
26034 swd = (weapon*)Lwpns.spr(i);
26035
26036 if(swd->id == (attack==wSword ? wSword : wWand))
26037 {
26038 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26039 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
26040 positionSword(swd,item_id);
26041 break;
26042 }
26043 }
26044 }
26045 154 lighting(false, true);
26046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 154 times.
154 if ( dontdraw < 2 ) { dontdraw=0; }
26047 154 stepforward(diagonalMovement?16:18, false);
26048 }
26049
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 585 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
585 if (get_qr(qr_SCREEN80_OWN_MUSIC) && (updatemusic || !musicnocut))
26050 {
26051 playLevelMusic();
26052 if (musicrevert)
26053 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26054 }
26055 585 break;
26056 }
26057
26058 case wtPASS: // passageway
26059 {
26060 // some draw_screen code (the passive subscreen compass dot) depends
26061 // on cur_screen being set before initiating the screen wipes for a warp.
26062 // Without this the compass dot would remain drawn while warping.
26063 // This is better, but for now this code keeps the rendering equivalent to before
26064 // z3 refactor.
26065 // demosp253.zplay and first_quest_layered.zplay showcases this behavior.
26066 // TODO(replays): remove in future bulk replay update.
26067 322 currscr_for_passive_subscr = 0x81;
26068
26069 322 kill_sfx();
26070 322 ALLOFF();
26071 //play sound
26072
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(warpsfx > 0) sfx(warpsfx,pan(x));
26073 322 specialcave = PASSAGEWAY;
26074 322 byte warp_screen_2 = wscr + DMaps[wdmap].xoff;
26075 322 draw_screen(false);
26076
26077
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if(!get_qr(qr_NEW_DARKROOM))
26078 {
26079
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 314 times.
322 if(!darkroom)
26080 314 fade(DMaps[cur_dmap].color,true,false);
26081
26082 322 darkroom=true;
26083 322 }
26084 else
26085 fade(DMaps[cur_dmap].color,true,false);
26086 322 blackscr(30,true);
26087 322 bool no_x80_dir = true;
26088 322 loadscr(wdmap, 0x81, down, false, no_x80_dir);
26089 322 scr = hero_scr;
26090 //preloaded freeform combos
26091 322 ffscript_engine(true);
26092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if ( dontdraw < 2 ) { dontdraw=1; }
26093 322 draw_screen(false);
26094 322 lighting(false, true);
26095
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if (get_qr(qr_NEW_DARKROOM))
26096 fade(0xB, false, true);
26097 322 dir=down;
26098 322 x=48;
26099
26100
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 174 times.
322 if((home_screen&15) > (warp_screen_2&15))
26101 {
26102 174 x=192;
26103 174 }
26104
26105
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 12 times.
322 if((home_screen&15) == (warp_screen_2&15))
26106 {
26107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if((cur_screen>>4) > (warp_screen_2>>4))
26108 {
26109 12 x=192;
26110 12 }
26111 12 }
26112
26113 // is this didpit check necessary?
26114
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(didpit)
26115 {
26116 didpit=false;
26117 x=pitx;
26118 y=pity;
26119 }
26120
26121 322 y=0;
26122 322 set_respawn_point();
26123 322 trySideviewLadder();
26124 322 reset_hookshot();
26125
1/2
✓ Branch 0 taken 322 times.
✗ Branch 1 not taken.
322 if(reposition_sword_postwarp)
26126 {
26127 weapon *swd=NULL;
26128 for(int32_t i=0; i<Lwpns.Count(); i++)
26129 {
26130 swd = (weapon*)Lwpns.spr(i);
26131
26132 if(swd->id == (attack==wSword ? wSword : wWand))
26133 {
26134 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26135 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
26136 positionSword(swd,item_id);
26137 break;
26138 }
26139 }
26140 }
26141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
322 if ( dontdraw < 2 ) { dontdraw=0; }
26142 322 stepforward(diagonalMovement?16:18, false);
26143 322 newscr_clk=frame;
26144 322 activated_timed_warp=false;
26145 322 stepoutindex=index;
26146 322 stepoutscreen = warp_screen_2;
26147 322 stepoutdmap = wdmap;
26148 322 stepoutwr=wrindex;
26149
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 322 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
322 if (get_qr(qr_SCREEN80_OWN_MUSIC) && (updatemusic || !musicnocut))
26150 {
26151 playLevelMusic();
26152 if (musicrevert)
26153 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26154 }
26155 }
26156 322 break;
26157
26158 case wtEXIT: // entrance/exit
26159 {
26160 1636 lighting(false,false,pal_litRESETONLY);//Reset permLit, and do nothing else; lighting was not otherwise called on a wtEXIT warp.
26161 1636 ALLOFF();
26162
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1636 if(updatemusic||!musicnocut)
26163 1636 music_stop();
26164 1636 kill_sfx();
26165 1636 blackscr(30,false);
26166 1636 bool changedlevel = false;
26167 1636 bool changeddmap = false;
26168
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1633 times.
1636 if(cur_dmap != wdmap)
26169 {
26170 1633 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26171 1633 changeddmap = true;
26172 1633 }
26173
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 1374 times.
1636 if(dlevel != DMaps[wdmap].level)
26174 {
26175 1374 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26176 1374 changedlevel = true;
26177 1374 }
26178 1636 dlevel = DMaps[wdmap].level;
26179 1636 cur_dmap = wdmap;
26180
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1633 times.
1636 if(changeddmap)
26181 {
26182 1633 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26183 1633 }
26184
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 1374 times.
1636 if(changedlevel)
26185 {
26186 1374 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26187 1374 }
26188
26189 1636 cur_map=DMaps[cur_dmap].map;
26190 1636 init_dmap();
26191 1636 update_subscreens(wdmap);
26192 1636 loadfullpal();
26193 1636 ringcolor(false);
26194 1636 loadlvlpal(DMaps[cur_dmap].color);
26195 1636 int destscr = wscr + DMaps[cur_dmap].xoff;
26196 1636 loadscr(cur_dmap, destscr, -1, overlay);
26197 1636 scr = hero_scr;
26198
26199
4/4
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1580 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 10 times.
1636 if (is_dark(scr) && !get_qr(qr_NEW_DARKROOM))
26200 {
26201
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 3 times.
10 if(get_qr(qr_FADE))
26202 {
26203 7 interpolatedfade();
26204 7 }
26205 else
26206 {
26207 3 loadfadepal((DMaps[cur_dmap].color)*pdLEVEL+poFADE3);
26208 }
26209
26210 10 darkroom=naturaldark=true;
26211 10 }
26212 else
26213 {
26214 1626 darkroom=naturaldark=false;
26215 }
26216
26217 int32_t wrx,wry;
26218
26219
2/2
✓ Branch 0 taken 655 times.
✓ Branch 1 taken 981 times.
1636 if(get_qr(qr_NOARRIVALPOINT))
26220 {
26221 655 wrx=scr->warpreturnx[0];
26222 655 wry=scr->warpreturny[0];
26223 655 }
26224 else
26225 {
26226 981 wrx=scr->warparrivalx;
26227 981 wry=scr->warparrivaly;
26228 }
26229
26230
6/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 1545 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 63 times.
✓ Branch 5 taken 1573 times.
1636 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!(scr->flags6&fNOCONTINUEHERE)))
26231 {
26232
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 460 times.
1573 if(dlevel)
26233 {
26234 1113 lastentrance = cur_screen;
26235 1113 }
26236 else
26237 {
26238 460 lastentrance = DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff;
26239 }
26240
26241 1573 lastentrance_dmap = wdmap;
26242 1573 }
26243
26244
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 523 times.
1636 if(dlevel)
26245 {
26246
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 554 times.
1113 if(get_qr(qr_NOARRIVALPOINT))
26247 {
26248 559 x=scr->warpreturnx[wrindex];
26249 559 y=scr->warpreturny[wrindex];
26250 559 }
26251 else
26252 {
26253 554 x=scr->warparrivalx;
26254 554 y=scr->warparrivaly;
26255 }
26256 1113 }
26257 else
26258 {
26259 523 x=scr->warpreturnx[wrindex];
26260 523 y=scr->warpreturny[wrindex];
26261 }
26262
26263
2/2
✓ Branch 0 taken 1627 times.
✓ Branch 1 taken 9 times.
1636 if(didpit)
26264 {
26265 9 didpit=false;
26266 9 x=pitx;
26267 9 y=pity;
26268 9 }
26269
26270 1636 dir=down;
26271
2/2
✓ Branch 0 taken 1608 times.
✓ Branch 1 taken 28 times.
1636 if(x==0) dir=right;
26272
2/2
✓ Branch 0 taken 1613 times.
✓ Branch 1 taken 23 times.
1636 if(x==240) dir=left;
26273
2/2
✓ Branch 0 taken 1598 times.
✓ Branch 1 taken 38 times.
1636 if(y==0) dir=down;
26274
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 628 times.
1636 if(y==160) dir=up;
26275
26276 1636 x += region_scr_dx * 256;
26277 1636 y += region_scr_dy * 176;
26278 1636 update_viewport();
26279
26280
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 1113 times.
1636 if(dlevel)
26281 {
26282 // reset enemy kill counts
26283
2/2
✓ Branch 0 taken 142464 times.
✓ Branch 1 taken 1113 times.
143577 for(int32_t i=0; i<128; i++)
26284 {
26285 142464 int mi = mapind(cur_map, i);
26286 142464 game->guys[mi] = 0;
26287 142464 game->maps[mi] &= ~mTMPNORET;
26288 142464 }
26289 1113 }
26290
26291 1636 markBmap(dir^1, current_screen);
26292 //preloaded freeform combos
26293 1636 ffscript_engine(true);
26294
26295 1636 reset_hookshot();
26296
1/2
✓ Branch 0 taken 1636 times.
✗ Branch 1 not taken.
1636 if(reposition_sword_postwarp)
26297 {
26298 weapon *swd=NULL;
26299 for(int32_t i=0; i<Lwpns.Count(); i++)
26300 {
26301 swd = (weapon*)Lwpns.spr(i);
26302
26303 if(swd->id == (attack==wSword ? wSword : wWand))
26304 {
26305 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26306 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
26307 positionSword(swd,item_id);
26308 break;
26309 }
26310 }
26311 }
26312
26313
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 1163 times.
1636 if(isdungeon())
26314 {
26315 473 openscreen();
26316
4/4
✓ Branch 0 taken 430 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 374 times.
473 if(get_er(er_SHORTDGNWALK)==0 && get_qr(qr_SHORTDGNWALK)==0)
26317 374 stepforward(diagonalMovement?11:12, false);
26318 else
26319 // Didn't walk as far pre-1.93, and some quests depend on that
26320 99 stepforward(8, false);
26321 473 }
26322 else
26323 {
26324
2/2
✓ Branch 0 taken 996 times.
✓ Branch 1 taken 167 times.
1163 if(!COOLSCROLL)
26325 167 openscreen();
26326
26327 1163 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type; // Old-style blue square placement
26328 1163 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26329 1163 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type; // More old-style blue square placement
26330
26331
10/10
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 31 times.
✓ Branch 3 taken 1024 times.
✓ Branch 4 taken 1004 times.
✓ Branch 5 taken 38 times.
✓ Branch 6 taken 27 times.
✓ Branch 7 taken 977 times.
✓ Branch 8 taken 25 times.
✓ Branch 9 taken 52 times.
1163 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26332 {
26333 202 reset_pal_cycling();
26334 202 walkup(COOLSCROLL);
26335 202 }
26336
10/10
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 28 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 951 times.
✓ Branch 4 taken 905 times.
✓ Branch 5 taken 74 times.
✓ Branch 6 taken 24 times.
✓ Branch 7 taken 881 times.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 25 times.
1029 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26337 {
26338 153 reset_pal_cycling();
26339 153 walkdown2(COOLSCROLL);
26340 153 }
26341
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 852 times.
906 else if(COOLSCROLL)
26342 {
26343 852 openscreen();
26344 852 }
26345 }
26346
26347 1678 show_subscreen_life=true;
26348 1678 show_subscreen_numbers=true;
26349
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1678 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 43 times.
1678 if (updatemusic || !musicnocut)
26350 {
26351 1721 playLevelMusic();
26352
1/2
✓ Branch 0 taken 1635 times.
✗ Branch 1 not taken.
1721 if (musicrevert)
26353 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26354 1635 }
26355 1678 currcset=DMaps[cur_dmap].color;
26356 1678 dointro();
26357 1678 set_respawn_point();
26358 1678 trySideviewLadder();
26359
26360
2/2
✓ Branch 0 taken 9810 times.
✓ Branch 1 taken 1678 times.
11488 for(int32_t i=0; i<6; i++)
26361 9810 visited[i]=-1;
26362
26363 1678 break;
26364 }
26365
26366 case wtSCROLL: // scrolling warp
26367 {
26368 893 int32_t c = DMaps[cur_dmap].color;
26369 893 scrolling_dmap = cur_dmap;
26370 893 scrolling_map = cur_map;
26371 893 cur_map = DMaps[wdmap].map;
26372 893 update_subscreens(wdmap);
26373
26374 893 dlevel = DMaps[wdmap].level;
26375 //check if Hero has the map for the new location before updating the subscreen. ? -Z
26376 //This works only in one direction, if Hero had a map, to not having one.
26377 //If Hero does not have a map, and warps somewhere where he does, then the map still briefly shows.
26378 893 update_subscreens(wdmap);
26379
26380 /*if ( has_item(itype_map, dlevel) )
26381 {
26382 //Blank the map during an intra-dmap scrolling warp.
26383 dlevel = -1; //a hack for the minimap. This works!! -Z
26384 }*/
26385
26386 // fix the scrolling direction, if it was a tile or instant warp
26387
2/4
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 893 times.
893 if(type==0 || type>=3)
26388 {
26389 sdir = dir;
26390 }
26391
26392 893 scrollscr(sdir, wscr+DMaps[wdmap].xoff, wdmap);
26393 893 scr = hero_scr;
26394
26395 893 reset_hookshot();
26396
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(reposition_sword_postwarp)
26397 {
26398 weapon *swd=NULL;
26399 for(int32_t i=0; i<Lwpns.Count(); i++)
26400 {
26401 swd = (weapon*)Lwpns.spr(i);
26402
26403 if(swd->id == (attack==wSword ? wSword : wWand))
26404 {
26405 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26406 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
26407 positionSword(swd,item_id);
26408 break;
26409 }
26410 }
26411 }
26412
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 786 times.
893 if(!intradmap)
26413 {
26414 786 init_dmap();
26415
26416 int32_t wrx,wry;
26417
26418
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 338 times.
786 if(get_qr(qr_NOARRIVALPOINT))
26419 {
26420 448 wrx=hero_scr->warpreturnx[0];
26421 448 wry=hero_scr->warpreturny[0];
26422 448 }
26423 else
26424 {
26425 338 wrx=hero_scr->warparrivalx;
26426 338 wry=hero_scr->warparrivaly;
26427 }
26428
26429
8/8
✓ Branch 0 taken 356 times.
✓ Branch 1 taken 430 times.
✓ Branch 2 taken 331 times.
✓ Branch 3 taken 25 times.
✓ Branch 4 taken 282 times.
✓ Branch 5 taken 504 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 270 times.
786 if(((wrx>0||wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))&&(!get_qr(qr_NOSCROLLCONTINUE))&&(!(scr->flags6&fNOCONTINUEHERE)))
26430 {
26431
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 195 times.
270 if(dlevel)
26432 {
26433 75 lastentrance = cur_screen;
26434 75 }
26435 else
26436 {
26437 195 lastentrance = DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff;
26438 }
26439
26440 270 lastentrance_dmap = wdmap;
26441 270 }
26442 786 }
26443
2/2
✓ Branch 0 taken 402 times.
✓ Branch 1 taken 491 times.
893 if(DMaps[cur_dmap].color != c)
26444 {
26445 491 lighting(false, true);
26446 491 }
26447
26448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if (updatemusic)
26449 {
26450 893 playLevelMusic();
26451
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if (musicrevert)
26452 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26453 893 }
26454 893 currcset=DMaps[cur_dmap].color;
26455 893 dointro();
26456 }
26457 893 break;
26458
26459 case wtWHISTLE: // whistle warp
26460 {
26461 125 scrolling_dmap = cur_dmap;
26462 125 scrolling_map = cur_map;
26463 125 cur_map = DMaps[wdmap].map;
26464 125 scrollscr(index, wscr+DMaps[wdmap].xoff, wdmap);
26465 125 scr = hero_scr;
26466 125 reset_hookshot();
26467 125 cur_dmap=wdmap;
26468 125 dlevel=DMaps[cur_dmap].level;
26469 125 lighting(false, true);
26470 125 init_dmap();
26471
26472
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if (updatemusic)
26473 {
26474 125 playLevelMusic();
26475
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if (musicrevert)
26476 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26477 125 }
26478 125 currcset=DMaps[cur_dmap].color;
26479 125 dointro();
26480 125 action=inwind; FFCore.setHeroAction(inwind);
26481 int32_t wry;
26482
26483
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 83 times.
125 if(get_qr(qr_NOARRIVALPOINT))
26484 42 wry=hero_scr->warpreturny[0];
26485 83 else wry=hero_scr->warparrivaly;
26486
26487 int32_t wrx;
26488
26489
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 83 times.
125 if(get_qr(qr_NOARRIVALPOINT))
26490 42 wrx=hero_scr->warpreturnx[0];
26491 83 else wrx=hero_scr->warparrivalx;
26492
26493 125 wrx += region_scr_dx * 256;
26494 125 wry += region_scr_dy * 176;
26495
26496 125 calculate_viewport(viewport, cur_dmap, cur_screen, world_w, world_h, wrx + Hero.txsz*16/2, wry + Hero.tysz*16/2);
26497
26498
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 123 times.
✓ Branch 2 taken 113 times.
✓ Branch 3 taken 10 times.
125 zfix whistle_x = index==left?viewport.right()-16:index==right?viewport.left():wrx;
26499
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 121 times.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 6 times.
125 zfix whistle_y = index==down?viewport.top():index==up?viewport.bottom()-16:wry;
26500
26501
3/6
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 125 times.
✗ Branch 5 not taken.
250 auto wind = new weapon(whistle_x,whistle_y,
26502
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 (zfix)0,wWind,1,0,index,whistleitem,getUID(),false,false,true,1);
26503 125 wind->screen_spawned = hero_scr->screen;
26504 125 Lwpns.add(wind);
26505 125 whirlwind=255;
26506 125 whistleitem=-1;
26507 }
26508 125 break;
26509
26510 case wtIWARP:
26511 case wtIWARPBLK:
26512 case wtIWARPOPEN:
26513 case wtIWARPZAP:
26514 case wtIWARPWAVE: // insta-warps
26515 {
26516 3636 bool old_192 = false;
26517
2/2
✓ Branch 0 taken 3592 times.
✓ Branch 1 taken 44 times.
3636 if (get_qr(qr_192b163_WARP))
26518 {
26519
1/2
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
44 if ( wtype == wtIWARPWAVE )
26520 {
26521 wtype = wtIWARPWAVE;
26522 old_192 = true;
26523 }
26524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if ( old_192 )
26525 {
26526 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Wave Warp.\n %s\n", "Trying to redirect it into a Cancel Effect");
26527 didpit=false;
26528 update_subscreens();
26529 warp_sound = 0;
26530 is_warping = false;
26531 return false;
26532 }
26533 44 }
26534 //for determining whether to exit cave
26535 3636 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26536 3636 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26537 3636 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26538
26539
8/8
✓ Branch 0 taken 3231 times.
✓ Branch 1 taken 405 times.
✓ Branch 2 taken 67 times.
✓ Branch 3 taken 3164 times.
✓ Branch 4 taken 3231 times.
✓ Branch 5 taken 67 times.
✓ Branch 6 taken 95 times.
✓ Branch 7 taken 3136 times.
7056 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
26540
8/8
✓ Branch 0 taken 3209 times.
✓ Branch 1 taken 73 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 3139 times.
✓ Branch 4 taken 69 times.
✓ Branch 5 taken 3208 times.
✓ Branch 6 taken 3150 times.
✓ Branch 7 taken 58 times.
3231 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
26541
26542 4054 bool kill_action = !(scr->flags3&fIWARP_SPRITE_CARRYOVER);
26543
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3241 times.
4054 if(kill_action)
26544 {
26545 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
26546 3241 bool wasswimming = (action == swimming);
26547 3241 int32_t olddiveclk = diveclk;
26548 3241 ALLOFF();
26549
26550
2/2
✓ Branch 0 taken 3205 times.
✓ Branch 1 taken 36 times.
3241 if(wasswimming)
26551 {
26552 36 Hero.SetSwim();
26553 36 diveclk = olddiveclk;
26554 36 }
26555
26556 3241 kill_sfx();
26557 3241 }
26558 //play sound
26559
2/2
✓ Branch 0 taken 3149 times.
✓ Branch 1 taken 95 times.
3244 if(warpsfx > 0) sfx(warpsfx,pan(x));
26560
2/2
✓ Branch 0 taken 590 times.
✓ Branch 1 taken 2654 times.
3244 if(wtype==wtIWARPZAP)
26561 {
26562 590 zapout();
26563 590 }
26564
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 2431 times.
2654 else if(wtype==wtIWARPWAVE)
26565 {
26566 //only draw Hero if he's not in a cave -DD
26567 223 wavyout(!cavewarp);
26568 223 }
26569
2/2
✓ Branch 0 taken 1509 times.
✓ Branch 1 taken 922 times.
2431 else if(wtype!=wtIWARP)
26570 {
26571
2/2
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 627 times.
922 bool b2 = COOLSCROLL&&cavewarp;
26572 922 blackscr(30,b2?false:true);
26573 922 }
26574
26575 3244 int32_t c = DMaps[cur_dmap].color;
26576 3244 bool changedlevel = false;
26577 3244 bool changeddmap = false;
26578
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 1728 times.
3244 if(cur_dmap != wdmap)
26579 {
26580 1728 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26581 1728 changeddmap = true;
26582 1728 }
26583
2/2
✓ Branch 0 taken 2654 times.
✓ Branch 1 taken 590 times.
3244 if(dlevel != DMaps[wdmap].level)
26584 {
26585 590 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26586 590 changedlevel = true;
26587 590 }
26588 3244 dlevel = DMaps[wdmap].level;
26589 3244 cur_dmap = wdmap;
26590
2/2
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 1728 times.
3244 if(changeddmap)
26591 {
26592 1728 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26593 1728 }
26594
2/2
✓ Branch 0 taken 2654 times.
✓ Branch 1 taken 590 times.
3244 if(changedlevel)
26595 {
26596 590 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26597 590 }
26598
26599 3244 cur_map = DMaps[cur_dmap].map;
26600 3244 init_dmap();
26601 3244 update_subscreens(wdmap);
26602
26603 3244 ringcolor(false);
26604
26605
2/2
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 883 times.
3244 if(DMaps[cur_dmap].color != c)
26606 883 loadlvlpal(DMaps[cur_dmap].color);
26607
26608 3244 auto prev_region = cur_region;
26609 3244 int prev_origin_screen = cur_screen;
26610 3244 loadscr(cur_dmap, wscr + DMaps[cur_dmap].xoff, -1, overlay);
26611 3244 scr = hero_scr;
26612 3244 lightingInstant(); // Also sets naturaldark
26613
26614 // In the case where we did not call ALLOFF, preserve the "enemies have spawned"
26615 // state for the new screen.
26616
2/2
✓ Branch 0 taken 3241 times.
✓ Branch 1 taken 3 times.
3244 if (!kill_action)
26617 {
26618 // Mark the "loaded_enemies" state true if the previous screen had it as true.
26619 // The new screen is attempted to be matched 1:1 with screens in the old region, but if
26620 // the regions are different sizes then the nearest screen is used (it's clamped).
26621 6 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
26622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 int previous_screen_x = zc_min(prev_region.screen_width, region_scr_x);
26623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 int previous_screen_y = zc_min(prev_region.screen_height, region_scr_y);
26624 3 int previous_screen = prev_origin_screen + previous_screen_x + previous_screen_y*16;
26625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (get_screen_state(previous_screen).loaded_enemies)
26626 3 get_screen_state(scr->screen).loaded_enemies = true;
26627 3 });
26628
26629 // Update "screen_spawned" for every sprite to keep it valid.
26630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
11 for_every_sprite([&](sprite& spr) {
26631 8 int x = get_region_relative_dx(spr.screen_spawned, prev_origin_screen);
26632 8 int y = get_region_relative_dy(spr.screen_spawned, prev_origin_screen);
26633
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 2 times.
8 x = zc_min(x, cur_region.screen_width);
26634
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 3 times.
8 y = zc_min(y, cur_region.screen_height);
26635 8 spr.screen_spawned = cur_screen + x + y*16;
26636 8 });
26637 3 }
26638
26639 3244 x = hero_scr->warpreturnx[wrindex];
26640 3244 y = hero_scr->warpreturny[wrindex];
26641
26642
2/2
✓ Branch 0 taken 1982 times.
✓ Branch 1 taken 1262 times.
3244 if(didpit)
26643 {
26644 1262 didpit=false;
26645 1262 x=pitx;
26646 1262 y=pity;
26647 1262 }
26648
26649 3244 type1 = combobuf[MAPCOMBO(x,y-16)].type;
26650 3244 type2 = combobuf[MAPCOMBO(x,y)].type;
26651 3244 type3 = combobuf[MAPCOMBO(x,y+16)].type;
26652
26653
2/2
✓ Branch 0 taken 3153 times.
✓ Branch 1 taken 91 times.
3244 if(x==0) dir=right;
26654
26655
2/2
✓ Branch 0 taken 3240 times.
✓ Branch 1 taken 4 times.
3244 if(x==240) dir=left;
26656
26657
2/2
✓ Branch 0 taken 3187 times.
✓ Branch 1 taken 57 times.
3244 if(y==0) dir=down;
26658
26659
2/2
✓ Branch 0 taken 3176 times.
✓ Branch 1 taken 68 times.
3244 if(y==160) dir=up;
26660
26661 3244 x += region_scr_dx * 256;
26662 3244 y += region_scr_dy * 176;
26663 3244 update_viewport();
26664
26665 3244 markBmap(dir^1, current_screen);
26666
26667 3244 int32_t checkwater = iswaterex_z3(MAPCOMBO(x,y+8), -1, x,y+(bigHitbox?8:12)); //iswaterex can be intensive, so let's avoid as many calls as we can.
26668
26669
10/16
✓ Branch 0 taken 3215 times.
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 29 times.
✓ Branch 6 taken 29 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 29 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 29 times.
✓ Branch 12 taken 29 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 29 times.
✓ Branch 15 taken 3215 times.
3273 if(checkwater && _walkflag(x,y+(bigHitbox?8:12),0,STANDING_Z_STATE) && current_item(itype_flippers) > 0 && current_item(itype_flippers) >= combobuf[checkwater].attribytes[0] && (!(combobuf[checkwater].usrflags&cflag1) || (itemsbuf[current_item_id(itype_flippers)].flags & item_flag3)))
26670 {
26671 29 hopclk=0xFF;
26672 29 SetSwim();
26673
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (!IsSideSwim()) attackclk = charging = spins = 0;
26674 29 }
26675 else
26676 {
26677 3215 action = none; FFCore.setHeroAction(none);
26678 }
26679 //preloaded freeform combos
26680 3244 ffscript_engine(true);
26681
26682 3244 putscr(hero_scr, scrollbuf, 0, 0);
26683 3244 putscrdoors(hero_scr, scrollbuf, 0, 0);
26684
26685
10/10
✓ Branch 0 taken 3232 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 67 times.
✓ Branch 3 taken 3165 times.
✓ Branch 4 taken 3232 times.
✓ Branch 5 taken 67 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 3152 times.
✓ Branch 8 taken 174 times.
✓ Branch 9 taken 254 times.
3244 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26686 {
26687 320 reset_pal_cycling();
26688 320 putscr(hero_scr, scrollbuf, 0, 0);
26689 320 putscrdoors(hero_scr, scrollbuf, 0, 0);
26690 320 walkup(COOLSCROLL);
26691 320 }
26692
9/10
✓ Branch 0 taken 3232 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 3142 times.
✓ Branch 4 taken 3229 times.
✓ Branch 5 taken 87 times.
✓ Branch 6 taken 76 times.
✓ Branch 7 taken 3153 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 76 times.
3406 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26693 {
26694 351 reset_pal_cycling();
26695 351 putscr(hero_scr, scrollbuf, 0, 0);
26696 351 putscrdoors(hero_scr, scrollbuf, 0, 0);
26697 351 walkdown2(COOLSCROLL);
26698 351 }
26699
2/2
✓ Branch 0 taken 588 times.
✓ Branch 1 taken 2641 times.
3229 else if(wtype==wtIWARPZAP)
26700 {
26701 588 zapin();
26702 588 }
26703
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 2421 times.
2641 else if(wtype==wtIWARPWAVE)
26704 {
26705 220 wavyin();
26706 220 }
26707
2/2
✓ Branch 0 taken 2283 times.
✓ Branch 1 taken 138 times.
2421 else if(wtype==wtIWARPOPEN)
26708 {
26709 138 openscreen();
26710 138 }
26711
1/2
✓ Branch 0 taken 3552 times.
✗ Branch 1 not taken.
3552 if(reposition_sword_postwarp)
26712 {
26713 weapon *swd=NULL;
26714 for(int32_t i=0; i<Lwpns.Count(); i++)
26715 {
26716 swd = (weapon*)Lwpns.spr(i);
26717
26718 if(swd->id == (attack==wSword ? wSword : wWand))
26719 {
26720 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26721 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
26722 positionSword(swd,item_id);
26723 break;
26724 }
26725 }
26726 }
26727 3552 show_subscreen_life=true;
26728 3552 show_subscreen_numbers=true;
26729
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 3244 times.
3552 if (updatemusic)
26730 {
26731 3244 playLevelMusic();
26732
1/2
✓ Branch 0 taken 3244 times.
✗ Branch 1 not taken.
3244 if (musicrevert)
26733 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
26734 3244 }
26735 3552 currcset=DMaps[cur_dmap].color;
26736 3552 dointro();
26737 3552 set_respawn_point();
26738 3552 trySideviewLadder();
26739 }
26740 3552 break;
26741
26742
26743 case wtNOWARP:
26744 {
26745 151 bool old_192 = false;
26746
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if (get_qr(qr_192b163_WARP))
26747 {
26748 wtype = wtIWARPWAVE;
26749 old_192 = true;
26750 }
26751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if ( old_192 )
26752 {
26753 al_trace("Encountered a warp in a 1.92b163 style quest, that was set as a Cancel Warp.\n %s\n", "Trying to redirect it into a Wave Effect");
26754 //for determining whether to exit cave
26755 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
26756 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
26757 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
26758
26759 bool cavewarp = ((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED)
26760 ||(type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D));
26761
26762 if(!(scr->flags3&fIWARP_SPRITE_CARRYOVER))
26763 {
26764 //ALLOFF kills the action, but we want to preserve Hero's action if he's swimming or diving -DD
26765 bool wasswimming = (action == swimming);
26766 int32_t olddiveclk = diveclk;
26767 ALLOFF();
26768
26769 if(wasswimming)
26770 {
26771 Hero.SetSwim();
26772 diveclk = olddiveclk;
26773 }
26774
26775 kill_sfx();
26776 }
26777 //play sound
26778 if(warpsfx > 0) sfx(warpsfx,pan(x));
26779 if(wtype==wtIWARPZAP)
26780 {
26781 zapout();
26782 }
26783 else if(wtype==wtIWARPWAVE)
26784 {
26785 //only draw Hero if he's not in a cave -DD
26786 wavyout(!cavewarp);
26787 }
26788 else if(wtype!=wtIWARP)
26789 {
26790 bool b2 = COOLSCROLL&&cavewarp;
26791 blackscr(30,b2?false:true);
26792 }
26793
26794 int32_t c = DMaps[cur_dmap].color;
26795 bool changedlevel = false;
26796 bool changeddmap = false;
26797 if(cur_dmap != wdmap)
26798 {
26799 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
26800 changeddmap = true;
26801 }
26802 if(dlevel != DMaps[wdmap].level)
26803 {
26804 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
26805 changedlevel = true;
26806 }
26807 dlevel = DMaps[wdmap].level;
26808 cur_dmap = wdmap;
26809 if(changeddmap)
26810 {
26811 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
26812 }
26813 if(changedlevel)
26814 {
26815 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
26816 }
26817 cur_map = DMaps[cur_dmap].map;
26818 init_dmap();
26819 update_subscreens(wdmap);
26820
26821 ringcolor(false);
26822
26823 if(DMaps[cur_dmap].color != c)
26824 loadlvlpal(DMaps[cur_dmap].color);
26825
26826 loadscr(cur_dmap, wscr + DMaps[cur_dmap].xoff, -1, overlay);
26827 scr = hero_scr;
26828 lightingInstant(); // Also sets naturaldark
26829
26830 x = hero_scr->warpreturnx[wrindex];
26831 y = hero_scr->warpreturny[wrindex];
26832
26833 if(didpit)
26834 {
26835 didpit=false;
26836 x=pitx;
26837 y=pity;
26838 }
26839
26840 type1 = combobuf[MAPCOMBO(x,y-16)].type;
26841 type2 = combobuf[MAPCOMBO(x,y)].type;
26842 type3 = combobuf[MAPCOMBO(x,y+16)].type;
26843
26844 if(x==0) dir=right;
26845
26846 if(x==240) dir=left;
26847
26848 if(y==0) dir=down;
26849
26850 if(y==160) dir=up;
26851
26852 x += region_scr_dx * 256;
26853 y += region_scr_dy * 176;
26854 update_viewport();
26855
26856 markBmap(dir^1, current_screen);
26857
26858 if(iswaterex_z3(MAPCOMBO(x,y+8), -1, x,y+8) && _walkflag(x,y+8,0,STANDING_Z_STATE) && current_item(itype_flippers))
26859 {
26860 hopclk=0xFF;
26861 SetSwim();
26862 if (!IsSideSwim()) attackclk = charging = spins = 0;
26863 }
26864 else
26865 {
26866 action = none;
26867 FFCore.setHeroAction(none);
26868 }
26869 //preloaded freeform combos
26870 ffscript_engine(true);
26871
26872 putscr(hero_scr, scrollbuf, 0, 0);
26873 putscrdoors(hero_scr, scrollbuf, 0, 0);
26874
26875 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
26876 {
26877 reset_pal_cycling();
26878 putscr(hero_scr, scrollbuf, 0, 0);
26879 putscrdoors(hero_scr, scrollbuf, 0, 0);
26880 walkup(COOLSCROLL);
26881 }
26882 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
26883 {
26884 reset_pal_cycling();
26885 putscr(hero_scr, scrollbuf, 0, 0);
26886 putscrdoors(hero_scr, scrollbuf, 0, 0);
26887 walkdown2(COOLSCROLL);
26888 }
26889 else if(wtype==wtIWARPZAP)
26890 {
26891 zapin();
26892 }
26893 else if(wtype==wtIWARPWAVE)
26894 {
26895 wavyin();
26896 }
26897 else if(wtype==wtIWARPOPEN)
26898 {
26899 openscreen();
26900 }
26901 if(reposition_sword_postwarp)
26902 {
26903 weapon *swd=NULL;
26904 for(int32_t i=0; i<Lwpns.Count(); i++)
26905 {
26906 swd = (weapon*)Lwpns.spr(i);
26907
26908 if(swd->id == (attack==wSword ? wSword : wWand))
26909 {
26910 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26911 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
26912 positionSword(swd,item_id);
26913 break;
26914 }
26915 }
26916 }
26917 show_subscreen_life=true;
26918 show_subscreen_numbers=true;
26919 playLevelMusic();
26920 currcset=DMaps[cur_dmap].color;
26921 dointro();
26922 set_respawn_point();
26923 trySideviewLadder();
26924 break;
26925 }
26926 else
26927 {
26928
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(reposition_sword_postwarp)
26929 {
26930 weapon *swd=NULL;
26931 for(int32_t i=0; i<Lwpns.Count(); i++)
26932 {
26933 swd = (weapon*)Lwpns.spr(i);
26934
26935 if(swd->id == (attack==wSword ? wSword : wWand))
26936 {
26937 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26938 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
26939 positionSword(swd,item_id);
26940 break;
26941 }
26942 }
26943 }
26944 151 didpit=false;
26945 151 update_subscreens();
26946 151 warp_sound = 0;
26947 151 is_warping = false;
26948 151 return false;
26949 }
26950 }
26951 default:
26952 didpit=false;
26953 update_subscreens();
26954 warp_sound = 0;
26955 is_warping = false;
26956 if(reposition_sword_postwarp)
26957 {
26958 weapon *swd=NULL;
26959 for(int32_t i=0; i<Lwpns.Count(); i++)
26960 {
26961 swd = (weapon*)Lwpns.spr(i);
26962
26963 if(swd->id == (attack==wSword ? wSword : wWand))
26964 {
26965 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
26966 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
26967 positionSword(swd,item_id);
26968 break;
26969 }
26970 }
26971 }
26972 return false;
26973 }
26974
26975 7155 currscr_for_passive_subscr = -1;
26976
26977 // Stop Hero from drowning!
26978
5/6
✓ Branch 0 taken 6804 times.
✓ Branch 1 taken 351 times.
✓ Branch 2 taken 6804 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 351 times.
✓ Branch 5 taken 6453 times.
7155 if(action==drowning || action==lavadrowning || action==sidedrowning)
26979 {
26980 702 drownclk=0;
26981 702 drownclk=0;
26982 702 action=none; FFCore.setHeroAction(none);
26983 702 }
26984
26985 6453 int32_t checkwater = iswaterex_z3(MAPCOMBO(x,y+(bigHitbox?8:12)), -1, x,y+(bigHitbox?8:12));
26986 // But keep him swimming if he ought to be!
26987 // Unless the water is too high levelled, in which case... well, he'll drown on transition probably anyways. -Dimi
26988
10/12
✓ Branch 0 taken 6790 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 6738 times.
✓ Branch 3 taken 52 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 52 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 52 times.
✓ Branch 8 taken 3 times.
✓ Branch 9 taken 49 times.
✓ Branch 10 taken 7088 times.
✓ Branch 11 taken 39 times.
6503 if(action!=rafting && checkwater && (_walkflag(x,y+(bigHitbox?8:12),0,STANDING_Z_STATE) || get_qr(qr_DROWN))
26989 //&& (current_item(itype_flippers) >= combobuf[checkwater].attribytes[0])
26990
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
52 && (action!=inwind))
26991 {
26992 39 hopclk=0xFF;
26993 39 SetSwim();
26994 39 }
26995
26996 7127 newscr_clk=frame;
26997 7127 activated_timed_warp=false;
26998 7127 eat_buttons();
26999
27000
2/2
✓ Branch 0 taken 1832 times.
✓ Branch 1 taken 5295 times.
7127 if(wtype!=wtIWARP)
27001 5295 attackclk=0;
27002
27003 7127 didstuff=0;
27004 7127 usecounts.clear();
27005 7127 map_bkgsfx(true);
27006 7127 loadside=dir^1;
27007 7127 whistleclk=-1;
27008
27009
3/4
✓ Branch 0 taken 6798 times.
✓ Branch 1 taken 329 times.
✓ Branch 2 taken 7127 times.
✗ Branch 3 not taken.
7127 if((z>0 || fakez>0) && isSideViewHero())
27010 {
27011 y-=z;
27012 y-=fakez;
27013 fakez=0;
27014 z=0;
27015 }
27016
2/2
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 6640 times.
7127 else if(!isSideViewHero())
27017 {
27018 6640 fall=0;
27019 6640 fakefall=0;
27020 6640 }
27021
27022 // If warping between top-down and sideview screens,
27023 // fix enemies that are carried over by Full Screen Warp
27024 7127 const bool tmpscr_is_sideview = isSideViewHero();
27025
27026
4/4
✓ Branch 0 taken 6642 times.
✓ Branch 1 taken 485 times.
✓ Branch 2 taken 6606 times.
✓ Branch 3 taken 36 times.
7127 if(!wasSideview && tmpscr_is_sideview)
27027 {
27028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 for(int32_t i=0; i<guys.Count(); i++)
27029 {
27030 if(guys.spr(i)->z > 0 || guys.spr(i)->fakez > 0)
27031 {
27032 guys.spr(i)->y -= guys.spr(i)->z;
27033 guys.spr(i)->y -= guys.spr(i)->fakez;
27034 guys.spr(i)->z = 0;
27035 guys.spr(i)->fakez = 0;
27036 }
27037
27038 if(((enemy*)guys.spr(i))->type!=eeTRAP && ((enemy*)guys.spr(i))->type!=eeSPINTILE)
27039 guys.spr(i)->yofs += 2;
27040 }
27041 36 }
27042
4/4
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 6929 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 34 times.
7091 else if(wasSideview && !tmpscr_is_sideview)
27043 {
27044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 for(int32_t i=0; i<guys.Count(); i++)
27045 {
27046 if(((enemy*)guys.spr(i))->type!=eeTRAP && ((enemy*)guys.spr(i))->type!=eeSPINTILE)
27047 guys.spr(i)->yofs -= 2;
27048 }
27049 34 }
27050
27051
6/6
✓ Branch 0 taken 4404 times.
✓ Branch 1 taken 2723 times.
✓ Branch 2 taken 430 times.
✓ Branch 3 taken 3974 times.
✓ Branch 4 taken 287 times.
✓ Branch 5 taken 179 times.
7127 if((DMaps[cur_dmap].type&dmfCONTINUE) || (cur_dmap==0&&get_qr(qr_DMAP_0_CONTINUE_BUG)))
27052 {
27053
2/2
✓ Branch 0 taken 1474 times.
✓ Branch 1 taken 1346 times.
3010 if(dlevel)
27054 {
27055 int32_t wrx,wry;
27056
27057
2/2
✓ Branch 0 taken 526 times.
✓ Branch 1 taken 820 times.
1346 if(get_qr(qr_NOARRIVALPOINT))
27058 {
27059 526 wrx=origin_scr->warpreturnx[0];
27060 526 wry=origin_scr->warpreturny[0];
27061 526 }
27062 else
27063 {
27064 820 wrx=origin_scr->warparrivalx;
27065 820 wry=origin_scr->warparrivaly;
27066 }
27067
27068
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 times.
1356 if((wtype == wtEXIT)
27069
10/10
✓ Branch 0 taken 954 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 68 times.
✓ Branch 3 taken 886 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 19 times.
✓ Branch 6 taken 14 times.
✓ Branch 7 taken 35 times.
✓ Branch 8 taken 10 times.
✓ Branch 9 taken 4 times.
1346 || (((wtype == wtSCROLL) && !intradmap) && ((wrx>0 || wry>0)||(get_qr(qr_WARPSIGNOREARRIVALPOINT)))))
27070 {
27071
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 392 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 28 times.
440 if(!(wtype==wtSCROLL)||!(get_qr(qr_NOSCROLLCONTINUE)))
27072 {
27073 412 game->set_continue_scrn(home_screen);
27074 412 }
27075
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 15 times.
28 else if(cur_dmap != game->get_continue_dmap())
27076 {
27077 15 game->set_continue_scrn(DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff);
27078 15 }
27079 440 }
27080 else
27081 {
27082
2/2
✓ Branch 0 taken 821 times.
✓ Branch 1 taken 85 times.
906 if(cur_dmap != game->get_continue_dmap())
27083 {
27084 85 game->set_continue_scrn(DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff);
27085 85 }
27086 }
27087 1346 }
27088 else
27089 {
27090 1474 game->set_continue_scrn(DMaps[cur_dmap].cont + DMaps[cur_dmap].xoff);
27091 }
27092
27093 2820 game->set_continue_dmap(cur_dmap);
27094 2820 lastentrance_dmap = cur_dmap;
27095 2820 lastentrance = game->get_continue_scrn();
27096 2820 }
27097
27098
1/2
✓ Branch 0 taken 6973 times.
✗ Branch 1 not taken.
6973 if(origin_scr->flags4&fAUTOSAVE)
27099 {
27100 save_game(true,0);
27101 }
27102
27103
2/2
✓ Branch 0 taken 6828 times.
✓ Branch 1 taken 145 times.
6973 if(origin_scr->flags6&fCONTINUEHERE)
27104 {
27105 145 lastentrance_dmap = cur_dmap;
27106 145 lastentrance = home_screen;
27107 145 }
27108
27109 6973 update_subscreens();
27110 6973 verifyBothWeapons();
27111
27112 static const char roomtype_names[rMAX][255] =
27113 {
27114 "(None)","Special Item","Pay for Info","Secret Money","Gamble",
27115 "Door Repair","Red Potion or Heart Container","Feed the Goriya","Level 9 Entrance",
27116 "Potion Shop","Shop","More Bombs","Leave Money or Life","10 Rupees",
27117 "3-Stair Warp","Ganon","Zelda", "-<item pond>", "1/2 Magic Upgrade", "Learn Slash",
27118 "More Arrows","Take One Item","Bottle Shop"
27119 };
27120
27121
2/2
✓ Branch 0 taken 6388 times.
✓ Branch 1 taken 585 times.
6973 if(wtype==wtCAVE)
27122 {
27123
2/2
✓ Branch 0 taken 431 times.
✓ Branch 1 taken 154 times.
585 if(DMaps[cur_dmap].flags&dmfGUYCAVES)
27124 862 Z_eventlog("Entered %s containing %s.\n",DMaps[cur_dmap].flags&dmfCAVES ? "Cave" : "Item Cellar",
27125 431 (char *)roomtype_names[special_warp_return_scr->room]);
27126 else
27127 154 Z_eventlog("Entered %s.",DMaps[cur_dmap].flags&dmfCAVES ? "Cave" : "Item Cellar");
27128 585 }
27129 12776 else Z_eventlog("Warped to DMap %d: %s, screen %d, via %s.\n", cur_dmap, DMaps[cur_dmap].name,cur_screen,
27130
2/2
✓ Branch 0 taken 491 times.
✓ Branch 1 taken 5897 times.
12285 wtype==wtPASS ? "Passageway" :
27131
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 4262 times.
10159 wtype==wtEXIT ? "Entrance/Exit" :
27132
2/2
✓ Branch 0 taken 893 times.
✓ Branch 1 taken 3369 times.
4262 wtype==wtSCROLL ? "Scrolling Warp" :
27133 3369 wtype==wtWHISTLE ? "Whistle Warp" :
27134 "Insta-Warp");
27135
27136 6973 eventlog_mapflags();
27137
1/2
✓ Branch 0 taken 6973 times.
✗ Branch 1 not taken.
6973 if(reposition_sword_postwarp)
27138 {
27139 weapon *swd=NULL;
27140 for(int32_t i=0; i<Lwpns.Count(); i++)
27141 {
27142 swd = (weapon*)Lwpns.spr(i);
27143
27144 if(swd->id == (attack==wSword ? wSword : wWand))
27145 {
27146 int32_t itype = (attack==wFire ? itype_candle : attack==wCByrna ? itype_cbyrna : attack==wWand ? itype_wand : attack==wHammer ? itype_hammer : itype_sword);
27147 int32_t item_id = (directWpn>-1 && itemsbuf[directWpn].type==itype) ? directWpn : current_item_id(itype);
27148 positionSword(swd,item_id);
27149 break;
27150 }
27151 }
27152 }
27153 6973 FFCore.clear_combo_scripts();
27154
4/4
✓ Branch 0 taken 2422 times.
✓ Branch 1 taken 4551 times.
✓ Branch 2 taken 2170 times.
✓ Branch 3 taken 252 times.
6973 if (!intradmap || get_qr(qr_WARPS_RESTART_DMAPSCRIPT))
27155 {
27156 6721 FFScript::deallocateAllScriptOwned(ScriptType::DMap, olddmap);
27157 6721 FFCore.initZScriptDMapScripts();
27158 6721 FFCore.initZScriptScriptedActiveSubscreen();
27159 6721 }
27160 6973 is_warping = false;
27161
2/2
✓ Branch 0 taken 6709 times.
✓ Branch 1 taken 264 times.
6973 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
27162 264 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
27163 6973 return true;
27164 7124 }
27165
27166 373 void HeroClass::exitcave()
27167 {
27168 373 bool updatemusic = FFCore.can_dmap_change_music(cur_dmap);
27169 373 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
27170
27171 373 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27172 373 loadscr(cur_dmap, home_screen, 255, false); // bogus direction
27173 373 x = hero_scr->warpreturnx[0];
27174 373 y = hero_scr->warpreturny[0];
27175
27176
1/2
✓ Branch 0 taken 373 times.
✗ Branch 1 not taken.
373 if(didpit)
27177 {
27178 didpit=false;
27179 x=pitx;
27180 y=pity;
27181 }
27182
27183
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 18 times.
373 if(x+y == 0)
27184 18 x = y = 80;
27185
27186 373 x += region_scr_dx*256;
27187 373 y += region_scr_dy*176;
27188 373 update_viewport();
27189
27190 373 int32_t type1 = combobuf[MAPCOMBO(x,y-16)].type;
27191 373 int32_t type2 = combobuf[MAPCOMBO(x,y)].type;
27192 373 int32_t type3 = combobuf[MAPCOMBO(x,y+16)].type;
27193
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 331 times.
724 bool b = COOLSCROLL &&
27194
4/4
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 211 times.
331 ((type1==cCAVE) || (type1>=cCAVEB && type1<=cCAVED) ||
27195
4/4
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 208 times.
211 (type2==cCAVE) || (type2>=cCAVEB && type2<=cCAVED) ||
27196
4/4
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 190 times.
208 (type3==cCAVE2) || (type3>=cCAVE2B && type3<=cCAVE2D) ||
27197
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 195 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 5 times.
190 (type2==cCAVE2) || (type2>=cCAVE2B && type2<=cCAVE2D));
27198 393 ALLOFF();
27199 393 blackscr(30,b?false:true);
27200 393 ringcolor(false);
27201 393 loadlvlpal(DMaps[cur_dmap].color);
27202 393 lighting(false, true);
27203
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 393 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 10 times.
393 if (updatemusic || !musicnocut)
27204 403 music_stop();
27205 413 kill_sfx();
27206 413 putscr(hero_scr, scrollbuf, 0, 0);
27207 413 putscrdoors(hero_scr, scrollbuf, 0, 0);
27208
27209
10/10
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 153 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 235 times.
✓ Branch 4 taken 237 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 232 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 7 times.
413 if((type1==cCAVE)||(type1>=cCAVEB && type1<=cCAVED) || (type2==cCAVE)||(type2>=cCAVEB && type2<=cCAVED))
27210 {
27211 166 walkup(COOLSCROLL);
27212 166 }
27213
9/10
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 214 times.
✓ Branch 4 taken 219 times.
✓ Branch 5 taken 5 times.
✓ Branch 6 taken 5 times.
✓ Branch 7 taken 214 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5 times.
239 else if((type3==cCAVE2)||(type3>=cCAVE2B && type3<=cCAVE2D) || (type2==cCAVE2)||(type2>=cCAVE2B && type2<=cCAVE2D))
27214 {
27215 22 walkdown2(COOLSCROLL);
27216 22 }
27217
27218 403 show_subscreen_life=true;
27219 403 show_subscreen_numbers=true;
27220
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 403 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
403 if (updatemusic || !musicnocut)
27221 403 playLevelMusic();
27222 403 currcset=DMaps[cur_dmap].color;
27223 403 dointro();
27224 403 newscr_clk=frame;
27225 403 activated_timed_warp=false;
27226 403 dir=down;
27227 403 set_respawn_point();
27228 403 eat_buttons();
27229 403 didstuff=0;
27230 403 usecounts.clear();
27231 403 map_bkgsfx(true);
27232 403 loadside=dir^1;
27233 403 }
27234
27235
27236 11096 void HeroClass::stepforward(int32_t steps, bool adjust)
27237 {
27238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11096 times.
11096 if ( FFCore.nostepforward ) return;
27239
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11096 times.
11096 if ( FFCore.temp_no_stepforward ) { FFCore.temp_no_stepforward = 0; return; }
27240 11096 zfix tx=x; //temp x
27241 11096 zfix ty=y; //temp y
27242 11096 zfix tstep(0); //temp single step distance
27243 11096 zfix s(0); //calculated step distance for all steps
27244 11096 z3step=2;
27245 11096 int32_t sh=shiftdir;
27246 11096 shiftdir=-1;
27247
27248
2/2
✓ Branch 0 taken 189538 times.
✓ Branch 1 taken 11096 times.
200634 for(int32_t i=steps; i>0; --i)
27249 {
27250
2/2
✓ Branch 0 taken 499 times.
✓ Branch 1 taken 189039 times.
189538 if(diagonalMovement)
27251 {
27252
3/4
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 236 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 263 times.
499 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
27253 {
27254 236 tstep = 1.5;
27255 236 }
27256 else
27257 {
27258 263 tstep=z3step;
27259 263 z3step=(z3step%2)+1;
27260 }
27261 499 }
27262 else
27263 {
27264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189039 times.
189039 if(get_qr(qr_NEW_HERO_MOVEMENT))
27265 {
27266 tstep = 1.5;
27267 }
27268 else
27269 {
27270
2/2
✓ Branch 0 taken 105445 times.
✓ Branch 1 taken 83594 times.
189039 tstep=lsteps[int32_t((dir<left)?ty:tx)&7];
27271
27272
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 60103 times.
✓ Branch 2 taken 45342 times.
✓ Branch 3 taken 38591 times.
✓ Branch 4 taken 45003 times.
189039 switch(dir)
27273 {
27274 case up:
27275 60103 ty-=tstep;
27276 60103 break;
27277
27278 case down:
27279 45342 ty+=tstep;
27280 45342 break;
27281
27282 case left:
27283 38591 tx-=tstep;
27284 38591 break;
27285
27286 case right:
27287 45003 tx+=tstep;
27288 45003 break;
27289 }
27290 }
27291 }
27292
27293 189538 s+=tstep;
27294 189538 }
27295
27296 11096 z3step=2;
27297
27298 11096 x = x.getInt();
27299 11096 y = y.getInt();
27300
2/2
✓ Branch 0 taken 200401 times.
✓ Branch 1 taken 11093 times.
211494 while(s>=0)
27301 {
27302
2/2
✓ Branch 0 taken 501 times.
✓ Branch 1 taken 199900 times.
200401 if(diagonalMovement)
27303 {
27304
5/6
✓ Branch 0 taken 467 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 445 times.
✓ Branch 4 taken 56 times.
✗ Branch 5 not taken.
501 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
27305 {
27306 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
27307 {
27308 walkable = false;
27309 shiftdir = -1;
27310 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
27311 switch(tdir)
27312 {
27313 case left:
27314 --x;
27315 break;
27316 case right:
27317 ++x;
27318 break;
27319 case up:
27320 --y;
27321 break;
27322 case down:
27323 ++y;
27324 break;
27325 }
27326 }
27327 else
27328 {
27329 walkable=false;
27330 shiftdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
27331 moveOld2(dir, 150);
27332 }
27333 }
27334 else
27335 {
27336
3/4
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 244 times.
501 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
27337 {
27338 257 s-=1.5;
27339 257 }
27340 else
27341 {
27342 244 s-=z3step;
27343 }
27344 501 walkable=true;
27345 501 moveOld2(dir, 150);
27346 }
27347
27348 501 shiftdir=-1;
27349 501 }
27350 else
27351 {
27352
3/6
✓ Branch 0 taken 111689 times.
✓ Branch 1 taken 88211 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 199900 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
199900 if((dir<left?x.getInt()&7:y.getInt()&7)&&adjust==true)
27353 {
27354 walkable=false;
27355 int32_t tdir=dir<left?(x.getInt()&8?left:right):(y.getInt()&8?down:up);
27356 switch(tdir)
27357 {
27358 case left:
27359 --x;
27360 break;
27361 case right:
27362 ++x;
27363 break;
27364 case up:
27365 --y;
27366 break;
27367 case down:
27368 ++y;
27369 break;
27370 }
27371 }
27372 else
27373 {
27374
2/4
✓ Branch 0 taken 199900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 199900 times.
199900 if(get_qr(qr_NEW_HERO_MOVEMENT) || IsSideSwim())
27375 {
27376 s-=1.5;
27377 }
27378
2/2
✓ Branch 0 taken 111689 times.
✓ Branch 1 taken 88211 times.
199900 else if(dir<left)
27379 {
27380 111689 s-=lsteps[y.getInt()&7];
27381 111689 }
27382 else
27383 {
27384 88211 s-=lsteps[x.getInt()&7];
27385 }
27386
27387 199900 moveOld2(dir, 150);
27388 }
27389 }
27390
27391
2/2
✓ Branch 0 taken 189308 times.
✓ Branch 1 taken 11093 times.
200401 if(s<0)
27392 {
27393 // Not quite sure how this is actually supposed to work.
27394 // There have to be two cases for each direction or Hero
27395 // either walks too far onto the screen or may get stuck
27396 // going through walk-through walls.
27397
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4002 times.
✓ Branch 2 taken 2455 times.
✓ Branch 3 taken 2115 times.
✓ Branch 4 taken 2521 times.
11093 switch(dir)
27398 {
27399 case up:
27400
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 3777 times.
4002 if(y<8) // Leaving the screen
27401 225 y+=s;
27402 else // Entering the screen
27403 3777 y-=s;
27404
27405 4002 break;
27406
27407 case down:
27408
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 2239 times.
2455 if(y>152)
27409 216 y-=s;
27410 else
27411 2239 y+=s;
27412
27413 2455 break;
27414
27415 case left:
27416
2/2
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 1940 times.
2115 if(x<8)
27417 175 x+=s;
27418 else
27419 1940 x-=s;
27420
27421 2115 break;
27422
27423 case right:
27424
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 2326 times.
2521 if(x>=232)
27425 195 x-=s;
27426 else
27427 2326 x+=s;
27428
27429 2521 break;
27430 }
27431 11093 }
27432
27433 200401 clear_darkroom_bitmaps();
27434 200401 update_viewport();
27435 200401 draw_screen();
27436
1/2
✓ Branch 0 taken 200401 times.
✗ Branch 1 not taken.
200401 if (canSideviewLadder()) setOnSideviewLadder(true);
27437 200401 advanceframe(true);
27438
27439
2/2
✓ Branch 0 taken 200398 times.
✓ Branch 1 taken 3 times.
200401 if(Quit)
27440 3 return;
27441 }
27442
4/4
✓ Branch 0 taken 8572 times.
✓ Branch 1 taken 2521 times.
✓ Branch 2 taken 2455 times.
✓ Branch 3 taken 6117 times.
11093 if(dir==right||dir==down)
27443 {
27444 4976 x=int32_t(x);
27445 4976 y=int32_t(y);
27446 4976 }
27447 else
27448 {
27449 6117 x = x.getInt();
27450 6117 y = y.getInt();
27451 }
27452 11093 set_respawn_point();
27453 11093 draw_screen();
27454 11093 eat_buttons();
27455 11093 shiftdir=sh;
27456 11096 }
27457
27458 1272 void HeroClass::setpit()
27459 {
27460 1272 didpit = true;
27461 1272 pitx = x.getInt() % 256;
27462 1272 pity = y.getInt() % 176;
27463 1272 }
27464
27465 458 void HeroClass::walkdown(bool opening) //entering cave
27466 {
27467
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 398 times.
458 if(opening)
27468 {
27469 398 close_black_opening(x+8, y+8+playing_field_offset, false);
27470 398 }
27471
27472 458 hclk=0;
27473 458 stop_item_sfx(itype_brang);
27474 458 sfx(WAV_STAIRS,pan(x));
27475 458 clk=0;
27476 // Fix Hero's position to the grid
27477 458 y=TRUNCATE_TILE(y.getInt());
27478 458 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
27479 458 attack=wNone;
27480 458 attackid=-1;
27481 458 reset_swordcharge();
27482 458 climb_cover_x=TRUNCATE_TILE(x.getInt());
27483 458 climb_cover_y=TRUNCATE_TILE(y.getInt()) + 16;
27484
27485 458 guys.clear();
27486 458 chainlinks.clear();
27487 458 Lwpns.clear();
27488 458 Ewpns.clear();
27489 458 items.clear();
27490
27491
2/2
✓ Branch 0 taken 458 times.
✓ Branch 1 taken 29312 times.
29770 for(int32_t i=0; i<64; i++)
27492 {
27493 29312 herostep();
27494
27495
2/4
✓ Branch 0 taken 29312 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29312 times.
29312 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27496 hero_count=(hero_count+1)%16;
27497
27498
2/2
✓ Branch 0 taken 21984 times.
✓ Branch 1 taken 7328 times.
29312 if((i&3)==3)
27499 {
27500 7328 ++y;
27501 7328 update_viewport();
27502 7328 }
27503
27504 29312 draw_screen();
27505 29312 advanceframe(true);
27506
27507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29312 times.
29312 if(Quit)
27508 break;
27509 29312 }
27510
27511 458 action=none; FFCore.setHeroAction(none);
27512 458 }
27513
27514 120 void HeroClass::walkdown2(bool opening) //exiting cave 2
27515 {
27516 120 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27517
27518
27519 // Fix Hero's position to the grid
27520 120 y=TRUNCATE_TILE(y.getInt());
27521
27522
3/6
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 99 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
120 if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
27523 99 y -= 16;
27524
27525 120 climb_cover_x=TRUNCATE_TILE(x.getInt());
27526 120 climb_cover_y=TRUNCATE_TILE(y.getInt());
27527
27528 120 dir=down;
27529 120 z=fakez=fall=fakefall=0;
27530
27531
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 25 times.
120 if(opening)
27532 {
27533 25 open_black_opening(x+8, y+8+playing_field_offset+16, false);
27534 25 }
27535
27536 120 hclk=0;
27537 120 stop_item_sfx(itype_brang);
27538 120 sfx(WAV_STAIRS,pan(x));
27539 120 clk=0;
27540 120 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
27541 120 attack=wNone;
27542 120 attackid=-1;
27543 120 reset_swordcharge();
27544
27545 120 guys.clear();
27546 120 chainlinks.clear();
27547 120 Lwpns.clear();
27548 120 Ewpns.clear();
27549 120 items.clear();
27550
27551
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 7680 times.
7800 for(int32_t i=0; i<64; i++)
27552 {
27553 7680 herostep();
27554
27555
2/4
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7680 times.
7680 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27556 hero_count=(hero_count+1)%16;
27557
27558
2/2
✓ Branch 0 taken 5760 times.
✓ Branch 1 taken 1920 times.
7680 if((i&3)==3)
27559 {
27560 1920 ++y;
27561 1920 update_viewport();
27562 1920 }
27563
27564 7680 draw_screen();
27565 7680 advanceframe(true);
27566
27567
1/2
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
7680 if(Quit)
27568 break;
27569 7680 }
27570
27571
27572 120 action=none; FFCore.setHeroAction(none);
27573 120 }
27574
27575 380 void HeroClass::walkup(bool opening) //exiting cave
27576 {
27577 380 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27578
27579
5/6
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 55 times.
✓ Branch 2 taken 26 times.
✓ Branch 3 taken 299 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 26 times.
380 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
27580 55 y+=16;
27581
27582 // Fix Hero's position to the grid
27583 380 y=TRUNCATE_TILE(y.getInt());
27584 380 z=fakez=fall=fakefall=0;
27585
27586
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 331 times.
380 if(opening)
27587 {
27588 331 open_black_opening(x+8, y+8+playing_field_offset-16, false);
27589 331 }
27590
27591 380 hclk=0;
27592 380 stop_item_sfx(itype_brang);
27593 380 sfx(WAV_STAIRS,pan(x));
27594 380 dir=down;
27595 380 clk=0;
27596 380 action=climbcoverbottom; FFCore.setHeroAction(climbcoverbottom);
27597 380 attack=wNone;
27598 380 attackid=-1;
27599 380 reset_swordcharge();
27600 380 climb_cover_x=TRUNCATE_TILE(x.getInt());
27601 380 climb_cover_y=TRUNCATE_TILE(y.getInt());
27602
27603 380 guys.clear();
27604 380 chainlinks.clear();
27605 380 Lwpns.clear();
27606 380 Ewpns.clear();
27607 380 items.clear();
27608
27609
2/2
✓ Branch 0 taken 380 times.
✓ Branch 1 taken 24320 times.
24700 for(int32_t i=0; i<64; i++)
27610 {
27611 24320 herostep();
27612
27613
2/4
✓ Branch 0 taken 24320 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24320 times.
24320 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27614 hero_count=(hero_count+1)%16;
27615
27616
2/2
✓ Branch 0 taken 18240 times.
✓ Branch 1 taken 6080 times.
24320 if((i&3)==0)
27617 {
27618 6080 --y;
27619 6080 update_viewport();
27620 6080 }
27621
27622 24320 draw_screen();
27623 24320 advanceframe(true);
27624
27625
1/2
✓ Branch 0 taken 24320 times.
✗ Branch 1 not taken.
24320 if(Quit)
27626 break;
27627 24320 }
27628
27629 380 map_bkgsfx(true);
27630 380 loadside=dir^1;
27631 380 action=none; FFCore.setHeroAction(none);
27632 380 }
27633
27634 423 void HeroClass::walkup2(bool opening) //entering cave2
27635 {
27636
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 327 times.
423 if(opening)
27637 {
27638 327 close_black_opening(x+8, y+8+playing_field_offset, false);
27639 327 }
27640
27641 423 hclk=0;
27642 423 stop_item_sfx(itype_brang);
27643 423 sfx(WAV_STAIRS,pan(x));
27644 423 dir=up;
27645 423 clk=0;
27646 423 action=climbcovertop; FFCore.setHeroAction(climbcovertop);
27647 423 attack=wNone;
27648 423 attackid=-1;
27649 423 reset_swordcharge();
27650 423 TRUNCATE_TILE(x.getInt());
27651 423 climb_cover_x=TRUNCATE_TILE(x.getInt());
27652 423 climb_cover_y=TRUNCATE_TILE(y.getInt()) - 16;
27653
27654 423 guys.clear();
27655 423 chainlinks.clear();
27656 423 Lwpns.clear();
27657 423 Ewpns.clear();
27658 423 items.clear();
27659
27660
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 27072 times.
27495 for(int32_t i=0; i<64; i++)
27661 {
27662 27072 herostep();
27663
27664
2/4
✓ Branch 0 taken 27072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27072 times.
27072 if(zinit.heroAnimationStyle==las_zelda3 || zinit.heroAnimationStyle==las_zelda3slow)
27665 hero_count=(hero_count+1)%16;
27666
27667
2/2
✓ Branch 0 taken 20304 times.
✓ Branch 1 taken 6768 times.
27072 if((i&3)==0)
27668 {
27669 6768 --y;
27670 6768 update_viewport();
27671 6768 }
27672
27673 27072 draw_screen();
27674 27072 advanceframe(true);
27675
27676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27072 times.
27072 if(Quit)
27677 break;
27678 27072 }
27679 423 map_bkgsfx(true);
27680 423 loadside=dir^1;
27681 423 action=none; FFCore.setHeroAction(none);
27682 423 }
27683
27684 455 void HeroClass::stepout() // Step out of item cellars and passageways
27685 {
27686 455 bool updatemusic = FFCore.can_dmap_change_music(cur_dmap);
27687 455 bool musicnocut = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_NOCUT;
27688
27689 455 int32_t sc = specialcave; // This gets erased by ALLOFF()
27690 455 ALLOFF();
27691 455 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
27692 455 kill_sfx();
27693 455 draw_screen(false);
27694 455 fade(sc>=GUYCAVE?10:11,true,false);
27695 455 blackscr(30,true);
27696 455 ringcolor(false);
27697
27698
4/4
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 271 times.
455 if(sc==PASSAGEWAY && abs(x-warpx)>16) // How did Hero leave the passageway?
27699 {
27700 271 cur_dmap=stepoutdmap;
27701 271 cur_map=DMaps[cur_dmap].map;
27702 271 dlevel=DMaps[cur_dmap].level;
27703
27704 //we might have just left a passage, so be sure to update the CSet record -DD
27705 271 currcset=DMaps[cur_dmap].color;
27706
27707 271 init_dmap();
27708 271 home_screen=stepoutscreen;
27709 271 }
27710
27711 455 loadscr(cur_dmap, home_screen, 255, false); // bogus direction
27712 455 draw_screen(false);
27713
27714
4/4
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 444 times.
✓ Branch 3 taken 10 times.
455 if(get_qr(qr_NEW_DARKROOM) || !is_dark(hero_scr))
27715 {
27716 445 darkroom = naturaldark = false;
27717 445 fade(DMaps[cur_dmap].color,true,true);
27718 445 }
27719 else
27720 {
27721 10 darkroom = naturaldark = true;
27722
27723
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if(get_qr(qr_FADE))
27724 {
27725 8 interpolatedfade();
27726 8 }
27727 else
27728 {
27729 2 loadfadepal((DMaps[cur_dmap].color)*pdLEVEL+poFADE3);
27730 }
27731 10 byte *si = colordata + CSET(DMaps[cur_dmap].color*pdLEVEL+poLEVEL)*3;
27732 10 si+=3*48;
27733
27734
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 10 times.
170 for(int32_t i=0; i<16; i++)
27735 {
27736 160 RAMpal[CSET(9)+i] = _RGB(si);
27737 160 tempgreypal[CSET(9)+i] = _RGB(si); //preserve monochrome
27738 160 si+=3;
27739 160 }
27740 }
27741
27742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 455 times.
455 if(didpit)
27743 {
27744 didpit=false;
27745 x=pitx;
27746 y=pity;
27747 }
27748 else
27749 {
27750 455 x = hero_scr->warpreturnx[stepoutwr];
27751 455 y = hero_scr->warpreturny[stepoutwr];
27752 }
27753
27754 455 x += region_scr_dx * 256;
27755 455 y += region_scr_dy * 176;
27756 455 update_viewport();
27757
27758
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 20 times.
455 if(x+y == 0)
27759 20 x = y = 80;
27760
27761 455 dir=down;
27762
27763 455 set_respawn_point();
27764
27765 // Let's use the 'exit cave' animation if we entered this cellar via a cave combo.
27766 455 int32_t type = combobuf[MAPCOMBO(x,y)].type;
27767
27768
4/6
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
455 if((type==cCAVE)||(type>=cCAVEB && type<=cCAVED))
27769 {
27770 walkup(false);
27771 }
27772
4/6
✓ Branch 0 taken 455 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 449 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
455 else if((type==cCAVE2)||(type>=cCAVE2B && type<=cCAVE2D))
27773 {
27774 walkdown2(false);
27775 }
27776
27777 455 newscr_clk=frame;
27778 455 activated_timed_warp=false;
27779 455 didstuff=0;
27780 455 usecounts.clear();
27781 455 eat_buttons();
27782 455 markBmap();
27783 455 map_bkgsfx(true);
27784
27785
2/2
✓ Branch 0 taken 401 times.
✓ Branch 1 taken 54 times.
455 if(!get_qr(qr_CAVEEXITNOSTOPMUSIC))
27786 {
27787
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
54 if (updatemusic || !musicnocut)
27788 {
27789 54 music_stop();
27790 54 playLevelMusic();
27791 54 }
27792 54 }
27793
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 else if(get_qr(qr_SCREEN80_OWN_MUSIC))
27794 {
27795 if (updatemusic || !musicnocut)
27796 playLevelMusic();
27797 }
27798
27799 455 loadside=dir^1;
27800 455 }
27801
27802 31559 bool HeroClass::nextcombo_wf(int32_t d2)
27803 {
27804
6/8
✓ Branch 0 taken 31497 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 31058 times.
✓ Branch 3 taken 439 times.
✓ Branch 4 taken 31058 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 439 times.
✗ Branch 7 not taken.
31559 if(toogam || (action!=swimming && !IsSideSwim() && action != swimhit) || hopclk==0) //!DIMITODO: ...does swimming just let you ignore smart scrolling entirely!?
27805 31559 return false;
27806
27807 // assumes Hero is about to scroll screens
27808 auto [map, screen] = nextscr2(d2);
27809 if (map == -1)
27810 return false;
27811
27812 const mapscr* scr = get_canonical_scr(map, screen);
27813
27814 int32_t cx = x;
27815 int32_t cy = y;
27816
27817 switch(d2)
27818 {
27819 case up:
27820 cy=160;
27821 break;
27822
27823 case down:
27824 cy=0;
27825 break;
27826
27827 case left:
27828 cx=240;
27829 break;
27830
27831 case right:
27832 cx=0;
27833 break;
27834 }
27835
27836 // check lower half of combo
27837 cy += 8;
27838
27839 int32_t cmb = COMBOPOS(cx%256, cy%176);
27840 const newcombo* c = &combobuf[scr->data[cmb]];
27841 bool dried = iswater_type(c->type) && DRIEDLAKE;
27842 bool swim = iswater_type(c->type) && (current_item(itype_flippers)) && !dried;
27843 int32_t b=1;
27844
27845 if(cx&8) b<<=2;
27846
27847 if(cy&8) b<<=1;
27848
27849 if((c->walk&b) && !dried && !swim)
27850 return true;
27851
27852 // next block (i.e. cnt==2)
27853 if(!(cx&8))
27854 {
27855 b<<=2;
27856 }
27857 else
27858 {
27859 c = &combobuf[scr->data[++cmb]];
27860 dried = iswater_type(c->type) && DRIEDLAKE;
27861 swim = iswater_type(c->type) && (current_item(itype_flippers)) && !dried;
27862 b=1;
27863
27864 if(cy&8)
27865 {
27866 b<<=1;
27867 }
27868 }
27869
27870 return (c->walk&b) ? !dried && !swim : false;
27871 31559 }
27872
27873 446 bool HeroClass::nextcombo_solid(int32_t d2)
27874 {
27875
2/4
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 446 times.
446 if(toogam || cur_screen>=128)
27876 return false;
27877
27878 // assumes Hero is about to scroll screens
27879 12406 auto [map, screen] = nextscr2(d2);
27880
1/2
✓ Branch 0 taken 446 times.
✗ Branch 1 not taken.
446 if (map == -1)
27881 return false;
27882
27883 446 int32_t cx = x;
27884 446 int32_t cy = y;
27885 446 cx %= 256;
27886 446 cy %= 176;
27887
27888
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 252 times.
446 switch(d2)
27889 {
27890 case up:
27891 20 cy=160;
27892 20 break;
27893
27894 case down:
27895 70 cy=0;
27896 70 break;
27897
27898 case left:
27899 104 cx=240;
27900 104 break;
27901
27902 case right:
27903 252 cx=0;
27904 252 break;
27905 }
27906
27907
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 426 times.
446 if(d2==up) cy += 8;
27908
27909
4/4
✓ Branch 0 taken 342 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 90 times.
446 if(d2==left||d2==right) cy+=bigHitbox?0:8;
27910
27911 446 int32_t initcx = cx;
27912 446 int32_t initcy = cy;
27913 446 bool smarter_scroll = get_qr(qr_SMARTER_SMART_SCROLL);
27914 // from MAPCOMBO()
27915
27916
10/10
✓ Branch 0 taken 406 times.
✓ Branch 1 taken 528 times.
✓ Branch 2 taken 382 times.
✓ Branch 3 taken 24 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 350 times.
✓ Branch 6 taken 232 times.
✓ Branch 7 taken 702 times.
✓ Branch 8 taken 674 times.
✓ Branch 9 taken 260 times.
934 for(int32_t i=0; i<=((bigHitbox&&!(d2==up||d2==down))?((initcy&7)?2:1):((initcy&7)?1:0)) && cy < 176; cy+=(cy%2)?7:8,i++)
27917 {
27918 674 cx = initcx;
27919
5/6
✓ Branch 0 taken 1684 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 1196 times.
✓ Branch 4 taken 1196 times.
✓ Branch 5 taken 488 times.
1684 for(int32_t k=0; k<=(smarter_scroll?((initcx&7)?2:1):0) && cx < 256; cx+=(cx%2)?7:8,k++)
27920 {
27921 2392 newcombo const& c = combobuf[MAPCOMBO3(map, screen, -1,cx,cy, smarter_scroll)];
27922
27923 1196 int32_t b=1;
27924
27925
2/2
✓ Branch 0 taken 644 times.
✓ Branch 1 taken 552 times.
1196 if(cx&8) b<<=2;
27926
27927
2/2
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 580 times.
1196 if(cy&8) b<<=1;
27928
27929 //bool bridgedetected = false;
27930
27931 1196 int32_t walk = c.walk;
27932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1196 times.
1196 if (smarter_scroll)
27933 {
27934
2/2
✓ Branch 0 taken 2392 times.
✓ Branch 1 taken 1196 times.
3588 for (int32_t m = 0; m <= 1; m++)
27935 {
27936 4784 newcombo const& cmb = combobuf[MAPCOMBO3(map, screen, m,cx,cy, true)];
27937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2392 times.
2392 if (cmb.type == cBRIDGE)
27938 {
27939 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
27940 {
27941 int efflag = (cmb.walk & 0xF0)>>4;
27942 int newsolid = (cmb.walk & 0xF);
27943 walk = ((newsolid | walk) & (~efflag)) | (newsolid & efflag);
27944 }
27945 else walk &= cmb.walk;
27946 }
27947 2392 else walk |= cmb.walk;
27948 2392 }
27949 1196 }
27950
27951
4/10
✓ Branch 0 taken 1196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1196 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1196 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
4784 bool swim = iswaterex(MAPCOMBO3(map, screen, -1,cx,cy, smarter_scroll), map, screen, -1, cx, cy, true, false, true) && (current_item(itype_flippers) || action==rafting);
27952
27953
3/4
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 1010 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 186 times.
1196 if((walk&b) && !swim)
27954 {
27955 186 return true;
27956 }
27957 1010 }
27958 488 }
27959
27960 260 return false;
27961 446 }
27962
27963 30436 void HeroClass::do_scroll_direction(direction dir)
27964 {
27965 30436 bool should_scroll = true;
27966
27967
5/6
✓ Branch 0 taken 30281 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 30281 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30291 times.
✓ Branch 5 taken 145 times.
30436 if((z > 0 || fakez > 0 || stomping) && get_qr(qr_NO_SCROLL_WHILE_IN_AIR))
27968 145 should_scroll = false;
27969
27970
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 30355 times.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
30436 if(lift_wpn && get_qr(qr_NO_SCROLL_WHILE_CARRYING))
27971 should_scroll = false;
27972
27973
1/2
✓ Branch 0 taken 30436 times.
✗ Branch 1 not taken.
30436 if(nextcombo_wf(dir))
27974 should_scroll = false;
27975
27976 30436 int dir_flag = 0;
27977
2/2
✓ Branch 0 taken 21640 times.
✓ Branch 1 taken 8796 times.
30436 if (dir == up) dir_flag = wfUP;
27978
2/2
✓ Branch 0 taken 7143 times.
✓ Branch 1 taken 14497 times.
21640 else if (dir == down) dir_flag = wfDOWN;
27979
2/2
✓ Branch 0 taken 6720 times.
✓ Branch 1 taken 7777 times.
14497 else if (dir == left) dir_flag = wfLEFT;
27980
1/2
✓ Branch 0 taken 7777 times.
✗ Branch 1 not taken.
7777 else if (dir == right) dir_flag = wfRIGHT;
27981 else assert(false);
27982
27983 30436 mapscr* scr = hero_scr;
27984
27985
9/10
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 29946 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 474 times.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 474 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 446 times.
✓ Branch 9 taken 28 times.
30436 if(get_qr(qr_SMARTSCREENSCROLL)&&(!(scr->flags&fMAZE))&&action!=inwind &&action!=scrolling && !(scr->flags2&dir_flag))
27986 {
27987
2/2
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 186 times.
446 if(nextcombo_solid(dir))
27988 186 should_scroll = false;
27989 446 }
27990
27991
4/4
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 30151 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 284 times.
30436 if (should_scroll || action == inwind)
27992 {
27993 30152 finish_auto_walk();
27994
2/2
✓ Branch 0 taken 801 times.
✓ Branch 1 taken 29349 times.
30152 if(cur_screen>=128)
27995 {
27996
2/2
✓ Branch 0 taken 346 times.
✓ Branch 1 taken 455 times.
801 if(specialcave >= GUYCAVE)
27997 346 exitcave();
27998 455 else stepout();
27999 801 }
28000
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 29223 times.
29349 else if(action==inwind)
28001 {
28002
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 125 times.
126 if(DMaps[cur_dmap].flags&dmfWHIRLWINDRET)
28003 {
28004 1 action=none; FFCore.setHeroAction(none);
28005 1 restart_level();
28006 1 }
28007 else
28008 {
28009 125 dowarp(scr, 2, dir);
28010 }
28011 126 }
28012
3/6
✓ Branch 0 taken 1943 times.
✓ Branch 1 taken 27280 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1943 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
29223 else if(scr->flags2&dir_flag && (!(scr->flags8&fMAZEvSIDEWARP) || checkmaze(scr,false)))
28013 {
28014 1943 sdir=dir;
28015 1943 dowarp(scr, 1, (scr->sidewarpindex >> (sdir*2))&3);
28016 1943 }
28017
4/4
✓ Branch 0 taken 26924 times.
✓ Branch 1 taken 356 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 26923 times.
27280 else if(!edge_of_dmap(dir) && edge_of_region(dir))
28018 {
28019 26923 scrolling_dmap = cur_dmap;
28020 26923 scrolling_map = cur_map;
28021 26923 scrollscr(dir);
28022
28023
1/2
✓ Branch 0 taken 26923 times.
✗ Branch 1 not taken.
26923 if(hero_scr->flags4&fAUTOSAVE)
28024 {
28025 save_game(true,0);
28026 }
28027
28028
2/2
✓ Branch 0 taken 26394 times.
✓ Branch 1 taken 529 times.
26923 if(hero_scr->flags6&fCONTINUEHERE)
28029 {
28030 529 lastentrance_dmap = cur_dmap;
28031 529 lastentrance = home_screen;
28032 529 }
28033 26923 }
28034 30150 }
28035 30434 }
28036
28037 142086 static bool has_advanced_maze(mapscr* scr)
28038 {
28039 142086 bool loopy = scr->flags10&fMAZE_LOOPY;
28040 142086 bool can_get_lost = scr->flags10&fMAZE_CAN_GET_LOST;
28041 142086 int maze_transition_wipe = scr->maze_transition_wipe;
28042
5/6
✓ Branch 0 taken 142080 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 142062 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 142062 times.
✗ Branch 5 not taken.
142086 return loopy || can_get_lost || maze_transition_wipe || is_in_scrolling_region();
28043 }
28044
28045 14322909 void HeroClass::maybe_begin_advanced_maze()
28046 {
28047
6/6
✓ Branch 0 taken 60486 times.
✓ Branch 1 taken 14262423 times.
✓ Branch 2 taken 60108 times.
✓ Branch 3 taken 378 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 60086 times.
14322909 if (!(hero_scr->flags&fMAZE) || current_screen == scrolling_maze_last_solved_screen || maze_state.active)
28048 14262823 return;
28049
28050 // Basic mazes are handled in scrollscr.
28051
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 60070 times.
60086 if (!has_advanced_maze(hero_scr))
28052 60070 return;
28053
28054 16 maze_state = {};
28055 maze_state.active = true;
28056 maze_state.loopy = hero_scr->flags10&fMAZE_LOOPY;
28057 maze_state.transition_wipe = hero_scr->maze_transition_wipe;
28058 maze_state.can_get_lost = hero_scr->flags10&fMAZE_CAN_GET_LOST;
28059 maze_state.scr = hero_scr;
28060 maze_state.exit_screen = screen_index_direction(current_screen, (direction)hero_scr->exitdir);
28061 maze_state.last_check_herox = x;
28062 maze_state.last_check_heroy = y;
28063
28064
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 if (maze_state.loopy)
28065 {
28066 6 int dx = get_region_relative_dx(prev_hero_scr->screen) - get_region_relative_dx(current_screen);
28067 6 int dy = get_region_relative_dy(prev_hero_scr->screen) - get_region_relative_dy(current_screen);
28068 6 maze_state.enter_dir = XY_DELTA_TO_DIR(sign2(dx), sign2(dy));
28069 6 }
28070 }
28071
28072 // Checks if hero is beyond the bounds of the screen, and if so begins scrolling.
28073 // Returns after scrolling is finished.
28074 14307785 void HeroClass::checkscroll()
28075 {
28076 //DO NOT scroll if Hero is vibrating due to Farore's Wind effect -DD
28077
3/4
✓ Branch 0 taken 14303887 times.
✓ Branch 1 taken 3898 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14303887 times.
14307785 if(action == casting||action==sideswimcasting)
28078 3898 return;
28079
28080
1/2
✓ Branch 0 taken 14303887 times.
✗ Branch 1 not taken.
14303887 if(!check_prescroll()) // prevent scrolling when you should drown/fall/etc before the screen edge
28081 return;
28082
28083
4/4
✓ Branch 0 taken 18355 times.
✓ Branch 1 taken 14285532 times.
✓ Branch 2 taken 9285 times.
✓ Branch 3 taken 9070 times.
14303887 if (action == inwind && whirlwind == 0)
28084 {
28085
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 8956 times.
9070 if (x > viewport.right()-16)
28086 {
28087 114 x = viewport.right()-16;
28088 114 do_scroll_direction(right);
28089 114 }
28090
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8954 times.
8956 else if (x < viewport.left())
28091 {
28092 2 x = viewport.left();
28093 2 do_scroll_direction(left);
28094 2 }
28095
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8950 times.
8954 else if (y > viewport.bottom()-16)
28096 {
28097 4 y = viewport.bottom()-16;
28098 4 do_scroll_direction(down);
28099 4 }
28100
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8944 times.
8950 else if (y < viewport.top())
28101 {
28102 6 y = viewport.top();
28103 6 do_scroll_direction(up);
28104 6 }
28105
28106 9070 return;
28107 }
28108
28109
2/2
✓ Branch 0 taken 7762 times.
✓ Branch 1 taken 14287055 times.
14294817 if (!maze_state.active)
28110 14287055 maybe_begin_advanced_maze();
28111
28112
2/2
✓ Branch 0 taken 14287047 times.
✓ Branch 1 taken 7770 times.
14294817 if (maze_state.active)
28113 {
28114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7770 times.
7770 if (action == inwind)
28115 {
28116 maze_state.active = false;
28117 return;
28118 }
28119
28120
2/2
✓ Branch 0 taken 3602 times.
✓ Branch 1 taken 4168 times.
7770 if (!maze_state.lost)
28121 {
28122
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4162 times.
4168 if (determine_hero_screen_from_coords()->screen == maze_state.exit_screen)
28123 {
28124 6 maze_state.active = false;
28125 6 update_current_screen();
28126 6 return;
28127 }
28128
28129
3/4
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 3608 times.
✓ Branch 2 taken 554 times.
✗ Branch 3 not taken.
4162 if (maze_state.enter_dir != dir_invalid && determine_hero_screen_from_coords() == prev_hero_scr)
28130 {
28131 maze_state.active = false;
28132 update_current_screen();
28133 return;
28134 }
28135 4162 }
28136
28137 7764 int maze_screen = maze_state.scr->screen;
28138 38820 auto [sx, sy] = translate_screen_coordinates_to_world(maze_screen);
28139
28140 7764 int x0 = x.getInt();
28141 7764 int y0 = y.getInt();
28142 7764 direction advance_dir = dir_invalid;
28143
5/6
✓ Branch 0 taken 7642 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 7642 times.
✓ Branch 3 taken 122 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7642 times.
15528 if (x0 > (sx+256)-16 || x0 > world_w - 16) advance_dir = right;
28144
5/6
✓ Branch 0 taken 7732 times.
✓ Branch 1 taken 32 times.
✓ Branch 2 taken 7732 times.
✓ Branch 3 taken 32 times.
✓ Branch 4 taken 7732 times.
✗ Branch 5 not taken.
15528 if (x0 < sx || x0 < 0) advance_dir = left;
28145
5/6
✓ Branch 0 taken 7718 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 7718 times.
✓ Branch 3 taken 46 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7718 times.
15528 if (y0 > (sy+176)-16 || y0 > world_h - 16) advance_dir = down;
28146
5/6
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 44 times.
✓ Branch 2 taken 7720 times.
✓ Branch 3 taken 44 times.
✓ Branch 4 taken 7720 times.
✗ Branch 5 not taken.
15528 if (y0 < sy || y0 < 0) advance_dir = up;
28147
28148
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 7520 times.
7764 if (advance_dir == dir_invalid)
28149 {
28150 7520 maze_state.last_check_herox = -10000;
28151 7520 maze_state.last_check_heroy = -10000;
28152 7520 }
28153 else
28154 {
28155
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 198 times.
244 bool can_check_again = std::abs(maze_state.last_check_herox - x0) >= 16 || std::abs(maze_state.last_check_heroy - y0) >= 16;
28156
28157
3/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
244 if (can_check_again && maze_enabled_sizewarp(maze_state.scr, advance_dir))
28158 {
28159 maze_state.active = false;
28160 return;
28161 }
28162
28163
4/4
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 146 times.
✓ Branch 2 taken 134 times.
✓ Branch 3 taken 12 times.
390 bool found_exit = !maze_state.lost && (lastdir[3] == maze_state.scr->exitdir || lastdir[3] == maze_state.enter_dir);
28164
2/2
✓ Branch 0 taken 134 times.
✓ Branch 1 taken 110 times.
244 if (found_exit)
28165 {
28166 // Do nothing.
28167 134 }
28168
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 6 times.
110 else if (can_check_again && checkmaze_ignore_exit(maze_state.scr, true))
28169 {
28170 6 maze_state.last_check_herox = x;
28171 6 maze_state.last_check_heroy = y;
28172 6 maze_state.enter_dir = dir_invalid;
28173
28174 6 int dest_screen = screen_index_direction(maze_screen, advance_dir);
28175
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
6 if (is_in_current_region(dest_screen))
28176 4 scrolling_maze_last_solved_screen = maze_screen;
28177 else
28178 2 scrollscr(advance_dir, dest_screen);
28179
28180 6 maze_state.active = false;
28181 6 }
28182
4/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 10 times.
104 else if (can_check_again && maze_state.loopy)
28183 {
28184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (maze_state.transition_wipe)
28185 10 closescreen(maze_state.transition_wipe - 1);
28186
28187
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if (advance_dir == left) x += 256;
28188
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if (advance_dir == right) x -= 256;
28189
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if (advance_dir == up) y += 176;
28190
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
10 if (advance_dir == down) y -= 176;
28191
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 6 times.
10 if (advance_dir == left || advance_dir == right)
28192 4 x.doClamp(0, world_w - 16);
28193
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
10 if (advance_dir == up || advance_dir == down)
28194 6 y.doClamp(0, world_h - 16);
28195
28196 10 maze_state.last_check_herox = x;
28197 10 maze_state.last_check_heroy = y;
28198 10 maze_state.enter_dir = dir_invalid;
28199
28200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (maze_state.can_get_lost)
28201 {
28202
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 if (advance_dir == maze_state.scr->exitdir)
28203 2 maze_state.lost = false;
28204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 else if (advance_dir != maze_state.enter_dir)
28205 8 maze_state.lost = true;
28206 10 }
28207
28208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (maze_state.transition_wipe)
28209 10 openscreen(maze_state.transition_wipe - 1);
28210 10 }
28211
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 22 times.
94 else if (!maze_state.loopy)
28212 {
28213
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (maze_state.transition_wipe)
28214 closescreen(maze_state.transition_wipe - 1);
28215
28216 22 loadscr(cur_dmap, current_screen, -1, false);
28217 22 maze_state.scr = get_scr(maze_screen);
28218
28219 // A bit janky, but works: clear all state (as usual during a screen change), but keep
28220 // the maze state.
28221 22 auto prev_maze_state = maze_state;
28222 22 ALLOFF();
28223 22 maze_state = prev_maze_state;
28224
28225
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
22 if (advance_dir == left) x = (get_region_relative_dx(maze_screen) + 1) * 256 - 16;
28226
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4 times.
22 if (advance_dir == right) x = (get_region_relative_dx(maze_screen)) * 256;
28227
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
22 if (advance_dir == up) y = (get_region_relative_dy(maze_screen) + 1) * 176 - 16;
28228
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 6 times.
22 if (advance_dir == down) y = (get_region_relative_dy(maze_screen)) * 176;
28229
28230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
22 if (maze_state.can_get_lost)
28231 {
28232
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 18 times.
22 if (advance_dir == maze_state.scr->exitdir)
28233 4 maze_state.lost = false;
28234 else
28235 18 maze_state.lost = true;
28236 22 }
28237
28238
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (maze_state.transition_wipe)
28239 openscreen(maze_state.transition_wipe - 1);
28240 22 }
28241 }
28242
28243
6/6
✓ Branch 0 taken 7758 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 4156 times.
✓ Branch 3 taken 3602 times.
✓ Branch 4 taken 4052 times.
✓ Branch 5 taken 104 times.
7764 if (maze_state.active && (maze_state.lost || advance_dir != maze_state.scr->exitdir))
28244 7654 return;
28245 110 }
28246
28247
2/2
✓ Branch 0 taken 14279494 times.
✓ Branch 1 taken 7663 times.
14287157 if (x > world_w-16)
28248 {
28249 7663 x = world_w-16;
28250 7663 do_scroll_direction(right);
28251 7663 }
28252
2/2
✓ Branch 0 taken 14280439 times.
✓ Branch 1 taken 6718 times.
14287157 if (x < 0)
28253 {
28254 6718 x = 0;
28255 6718 do_scroll_direction(left);
28256 6718 }
28257
2/2
✓ Branch 0 taken 14280018 times.
✓ Branch 1 taken 7139 times.
14287157 if (y > world_h-16)
28258 {
28259 7139 y = world_h-16;
28260 7139 do_scroll_direction(down);
28261 7139 }
28262
2/2
✓ Branch 0 taken 14278367 times.
✓ Branch 1 taken 8790 times.
14287157 if (y < 0)
28263 {
28264 8790 y = 0;
28265 8790 do_scroll_direction(up);
28266 8790 }
28267 14307785 }
28268
28269 14303887 bool HeroClass::check_prescroll()
28270 {
28271
2/2
✓ Branch 0 taken 14292693 times.
✓ Branch 1 taken 11194 times.
14303887 if(get_qr(qr_BROKEN_SCROLL_INSTEAD_OF_DROWN_FALL))
28272 14292693 return true; // skip checks
28273
8/8
✓ Branch 0 taken 11188 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 11185 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 11182 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 2 times.
✓ Branch 7 taken 11180 times.
11194 if (x <= world_w-16 && x >= 0 && y <= world_h-16 && y >= 0)
28274 11180 return true; // in bounds, no need for checks
28275 14 zfix tx = x, ty = y, tz = z;
28276 14 x = vbound(x, 0, world_w-16);
28277 14 y = vbound(y, 0, world_h-16);
28278
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(onWater(true) || drownclk)
28279 return false; // would drown before scrolling
28280
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(pitslide() || fallclk)
28281 return false; // would fall before scrolling
28282 14 x = tx; y = ty; z = tz;
28283 14 return true;
28284 14303887 }
28285
28286 // assumes current direction is in lastdir[3]
28287 // compares directions with scr->path and scr->exitdir
28288 107710 bool HeroClass::checkmaze(const mapscr *scr, bool sound)
28289 {
28290
2/2
✓ Branch 0 taken 106989 times.
✓ Branch 1 taken 721 times.
107710 if(!(scr->flags&fMAZE))
28291 106989 return true;
28292
28293
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 636 times.
721 if(lastdir[3]==scr->exitdir)
28294 85 return true;
28295
28296
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 99 times.
1113 for(int32_t i=0; i<4; i++)
28297
2/2
✓ Branch 0 taken 477 times.
✓ Branch 1 taken 537 times.
1014 if(lastdir[i]!=scr->path[i])
28298 537 return false;
28299
28300
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 33 times.
99 if(sound)
28301 33 sfx(scr->secretsfx);
28302
28303 99 return true;
28304 107710 }
28305
28306 // assumes current direction is in lastdir[3]
28307 // compares directions with scr->path and scr->exitdir
28308 38 bool HeroClass::checkmaze_ignore_exit(const mapscr *scr, bool sound)
28309 {
28310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(!(scr->flags&fMAZE))
28311 return true;
28312
28313
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 6 times.
64 for(int32_t i=0; i<4; i++)
28314
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 32 times.
58 if(lastdir[i]!=scr->path[i])
28315 32 return false;
28316
28317
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(sound)
28318 6 sfx(scr->secretsfx);
28319
28320 6 return true;
28321 38 }
28322
28323 54046 bool HeroClass::edge_of_dmap(int32_t side)
28324 {
28325
4/4
✓ Branch 0 taken 53862 times.
✓ Branch 1 taken 184 times.
✓ Branch 2 taken 53643 times.
✓ Branch 3 taken 219 times.
54046 if (!has_advanced_maze(origin_scr) && checkmaze(origin_scr, false) == false)
28326 219 return false;
28327
28328 // needs fixin'
28329 // should check dmap style
28330
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 15590 times.
✓ Branch 2 taken 11430 times.
✓ Branch 3 taken 12656 times.
✓ Branch 4 taken 14151 times.
53827 switch(side)
28331 {
28332 case up:
28333 15590 return current_screen<16;
28334
28335 case down:
28336 11430 return current_screen>=112;
28337
28338 case left:
28339
2/2
✓ Branch 0 taken 12521 times.
✓ Branch 1 taken 135 times.
12656 if((current_screen&15)==0)
28340 135 return true;
28341
28342
2/2
✓ Branch 0 taken 7109 times.
✓ Branch 1 taken 5412 times.
12521 if((DMaps[cur_dmap].type&dmfTYPE)!=dmOVERW)
28343 // if(dlevel)
28344 7109 return (((current_screen&15)-DMaps[cur_dmap].xoff)<=0);
28345
28346 5412 break;
28347
28348 case right:
28349
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 14039 times.
14151 if((current_screen&15)==15)
28350 112 return true;
28351
28352
2/2
✓ Branch 0 taken 7837 times.
✓ Branch 1 taken 6202 times.
14039 if((DMaps[cur_dmap].type&dmfTYPE)!=dmOVERW)
28353 // if(dlevel)
28354 7837 return (((current_screen&15)-DMaps[cur_dmap].xoff)>=7);
28355
28356 6202 break;
28357 }
28358
28359 11614 return false;
28360 54046 }
28361
28362 111816 static std::pair<int, int> lookahead_coords(int scrolldir, int x, int y)
28363 {
28364 111816 x = vbound(x, 0, world_w - 16);
28365 111816 y = vbound(y, 0, world_h - 16);
28366 111816 return {x, y};
28367 }
28368
28369 // Helper for scrollscr that gets next combo on next screen.
28370 27954 static int32_t lookahead(int32_t scrolldir, int x, int y)
28371 {
28372 55908 auto [cx, cy] = lookahead_coords(scrolldir, x, y);
28373 55908 return MAPCOMBO(cx, cy);
28374 }
28375
28376 454 static bool lookaheadraftflag(int scroll_dir, int x, int y)
28377 {
28378 454 int cx = x;
28379 454 int cy = y + 8;
28380 454 bound(cx, 0, world_w - 16);
28381 454 bound(cy, 0, world_h - 8);
28382
28383 454 auto rpos_handle = get_rpos_handle_for_world_xy(cx, cy, 0);
28384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 454 times.
454 return (isRaftFlag(rpos_handle.cflag()) || isRaftFlag(rpos_handle.sflag()));
28385 }
28386
28387 3267836 void HeroClass::run_scrolling_script_int(bool waitdraw)
28388 {
28389
2/2
✓ Branch 0 taken 1632996 times.
✓ Branch 1 taken 1634840 times.
3267836 if(waitdraw)
28390 {
28391
3/4
✓ Branch 0 taken 1632996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1143144 times.
✓ Branch 3 taken 489852 times.
1632996 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
28392 {
28393 489852 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
28394 489852 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
28395 489852 }
28396 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
28397
5/6
✓ Branch 0 taken 1632339 times.
✓ Branch 1 taken 657 times.
✓ Branch 2 taken 48739 times.
✓ Branch 3 taken 1583600 times.
✓ Branch 4 taken 48739 times.
✗ Branch 5 not taken.
1632996 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Hero) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28398 {
28399 48739 ZScriptVersion::RunScript(ScriptType::Hero, SCRIPT_HERO_ACTIVE);
28400 48739 FFCore.waitdraw(ScriptType::Hero) = false;
28401 48739 }
28402 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
28403
4/6
✓ Branch 0 taken 1632996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5575 times.
✓ Branch 3 taken 1627421 times.
✓ Branch 4 taken 5575 times.
✗ Branch 5 not taken.
1632996 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28404 {
28405 5575 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[cur_dmap].script,cur_dmap);
28406 5575 FFCore.waitdraw(ScriptType::DMap) = false;
28407 5575 }
28408 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
28409
2/6
✓ Branch 0 taken 1632996 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1632996 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1632996 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28410 {
28411 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script,cur_dmap);
28412 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
28413 }
28414 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
28415
28416
4/4
✓ Branch 0 taken 123494 times.
✓ Branch 1 taken 1509502 times.
✓ Branch 2 taken 590 times.
✓ Branch 3 taken 122904 times.
1632996 if (FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && !FFCore.system_suspend[susptSCREENSCRIPTS])
28417 {
28418 298738 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
28419
5/6
✓ Branch 0 taken 2384 times.
✓ Branch 1 taken 173450 times.
✓ Branch 2 taken 400 times.
✓ Branch 3 taken 1984 times.
✓ Branch 4 taken 400 times.
✗ Branch 5 not taken.
175834 if (scr->script != 0 && FFCore.waitdraw(ScriptType::Screen, scr->screen) && scr->preloadscript)
28420 {
28421 400 ZScriptVersion::RunScript(ScriptType::Screen, scr->script, scr->screen);
28422 400 FFCore.waitdraw(ScriptType::Screen, scr->screen) = 0;
28423 400 }
28424 175834 });
28425 122904 }
28426 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
28427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1632996 times.
1632996 if ( !FFCore.system_suspend[susptITEMSCRIPTENGINE] )
28428 {
28429 1632996 FFCore.itemScriptEngineOnWaitdraw();
28430 1632996 }
28431 1632996 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
28432 1632996 }
28433 else
28434 {
28435
4/4
✓ Branch 0 taken 125338 times.
✓ Branch 1 taken 1509502 times.
✓ Branch 2 taken 590 times.
✓ Branch 3 taken 124748 times.
1634840 if (FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && !FFCore.system_suspend[susptSCREENSCRIPTS])
28436 {
28437 303202 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
28438
4/4
✓ Branch 0 taken 2428 times.
✓ Branch 1 taken 176026 times.
✓ Branch 2 taken 1403 times.
✓ Branch 3 taken 1025 times.
178454 if (scr->script != 0 && scr->preloadscript)
28439 {
28440 1403 ZScriptVersion::RunScript(ScriptType::Screen, scr->script, scr->screen);
28441 1403 }
28442 178454 });
28443 124748 }
28444 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS);
28445
3/4
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1091695 times.
✓ Branch 3 taken 543145 times.
1634840 if ((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.doscript(ScriptType::Global, GLOBAL_SCRIPT_GAME))
28446 {
28447 543145 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
28448 543145 }
28449 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_ACTIVE);
28450
6/6
✓ Branch 0 taken 1634182 times.
✓ Branch 1 taken 658 times.
✓ Branch 2 taken 1558716 times.
✓ Branch 3 taken 75466 times.
✓ Branch 4 taken 1509502 times.
✓ Branch 5 taken 49214 times.
1634840 if ((!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.doscript(ScriptType::Hero) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255)
28451 {
28452 49214 ZScriptVersion::RunScript(ScriptType::Hero, SCRIPT_HERO_ACTIVE);
28453 49214 }
28454 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_ACTIVE);
28455
5/6
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1634248 times.
✓ Branch 3 taken 592 times.
✓ Branch 4 taken 1509502 times.
✓ Branch 5 taken 124746 times.
1634840 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28456 {
28457 124746 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[cur_dmap].script,cur_dmap);
28458 124746 }
28459 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE);
28460
4/6
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1634840 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1509502 times.
✓ Branch 5 taken 125338 times.
1634840 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
28461 {
28462 125338 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script,cur_dmap);
28463 125338 }
28464 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN);
28465 1634840 bool old = get_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING);
28466
3/4
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68390 times.
✓ Branch 3 taken 1566450 times.
1634840 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && old)
28467 1566450 FFCore.itemScriptEngine();
28468 1634840 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_OLD_ITEMDATA_SCRIPT);
28469
3/4
✓ Branch 0 taken 1634840 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1566450 times.
✓ Branch 3 taken 68390 times.
1634840 if(!FFCore.system_suspend[susptITEMSCRIPTENGINE] && !old)
28470 68390 FFCore.itemScriptEngine();
28471 }
28472 3267836 }
28473
28474 824 static zfix new_hero_x, new_hero_y;
28475 static int new_region_offset_x, new_region_offset_y;
28476 static region_t scrolling_new_region;
28477
28478 3234993 void HeroClass::run_scrolling_script_old(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
28479 {
28480 // For rafting (and possibly other esoteric things)
28481 // Hero's action should remain unchanged while scrolling,
28482 // but for the sake of scripts, here's an eye-watering kludge.
28483 3234993 actiontype lastaction = action;
28484 3234993 action=scrolling; FFCore.setHeroAction(scrolling);
28485
2/2
✓ Branch 0 taken 1616683 times.
✓ Branch 1 taken 1618310 times.
3234993 if(waitdraw)
28486 {
28487 1616683 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
28488 1616683 }
28489 else
28490 {
28491 1618310 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
28492 }
28493
28494 // Also, hero coordinates should remain unchanged.
28495 // For compat, this is happening after the generic scripts above...
28496 3234993 zfix storex = x, storey = y;
28497
28498
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 811700 times.
✓ Branch 2 taken 584957 times.
✓ Branch 3 taken 858345 times.
✓ Branch 4 taken 979991 times.
3234993 switch(scrolldir)
28499 {
28500 case up:
28501
2/2
✓ Branch 0 taken 669768 times.
✓ Branch 1 taken 141932 times.
811700 if(y < scrolling_new_region.height - 16) y = scrolling_new_region.height;
28502
4/4
✓ Branch 0 taken 118844 times.
✓ Branch 1 taken 23088 times.
✓ Branch 2 taken 52878 times.
✓ Branch 3 taken 65966 times.
141932 else if(cx > 0 && !end_frames) y = sy + scrolling_new_region.height - 20;
28503 75966 else y = scrolling_new_region.height - 16;
28504
28505 811700 x = new_hero_x;
28506 811700 break;
28507
28508 case down:
28509
2/2
✓ Branch 0 taken 476279 times.
✓ Branch 1 taken 108678 times.
584957 if(y > 0) y = -16;
28510
4/4
✓ Branch 0 taken 90765 times.
✓ Branch 1 taken 17913 times.
✓ Branch 2 taken 40026 times.
✓ Branch 3 taken 50739 times.
108678 else if(cx > 0 && !end_frames) y = sy - 172;
28511 57939 else y = 0;
28512
28513 584957 x = new_hero_x;
28514 584957 break;
28515
28516 case left:
28517
2/2
✓ Branch 0 taken 786764 times.
✓ Branch 1 taken 71581 times.
858345 if(x < scrolling_new_region.width - 16) x = scrolling_new_region.width;
28518
2/2
✓ Branch 0 taken 58288 times.
✓ Branch 1 taken 13293 times.
71581 else if(cx > 0) x = sx + scrolling_new_region.width - 20;
28519 13293 else x = scrolling_new_region.width - 16;
28520
28521 858345 y = new_hero_y;
28522 858345 break;
28523
28524 case right:
28525
2/2
✓ Branch 0 taken 898481 times.
✓ Branch 1 taken 81510 times.
979991 if(x > 0) x = -16;
28526
2/2
✓ Branch 0 taken 66446 times.
✓ Branch 1 taken 15064 times.
81510 else if(cx > 0) x = sx - 252;
28527 15064 else x = 0;
28528
28529 979991 y = new_hero_y;
28530 979991 break;
28531 }
28532
28533 3234993 viewport.x -= new_region_offset_x;
28534 3234993 viewport.y -= new_region_offset_y;
28535
28536 3234993 run_scrolling_script_int(waitdraw);
28537
28538 3234993 viewport.x += new_region_offset_x;
28539 3234993 viewport.y += new_region_offset_y;
28540
28541 3234993 x = storex, y = storey;
28542 3234993 action=lastaction; FFCore.setHeroAction(lastaction);
28543 3234993 }
28544
28545 3267836 void HeroClass::run_scrolling_script(int32_t scrolldir, int32_t cx, int32_t sx, int32_t sy, bool end_frames, bool waitdraw)
28546 {
28547
2/2
✓ Branch 0 taken 3234993 times.
✓ Branch 1 taken 32843 times.
3267836 if (get_qr(qr_BROKEN_SCRIPTS_SCROLLING_HERO_POSITION))
28548 {
28549 // Old code has an off-by-one error, and doesn't clamp the hero position to the viewport.
28550 //
28551 // Although this is behind a compat qr, most test replays wouldn't fail. The ones that do are:
28552 //
28553 // nargads: different sfx plays during last frames of scrolling, sometimes
28554 // crucible: fog is slightly different on last frames of scrolling
28555 // yuurand: breaks. blocks are not removed when returning to a screen during scroll
28556 3234993 run_scrolling_script_old(scrolldir, cx, sx, sy, end_frames, waitdraw);
28557 3234993 return;
28558 }
28559
28560 // For rafting (and possibly other esoteric things)
28561 // Hero's action should remain unchanged while scrolling,
28562 // but for the sake of scripts, here's an eye-watering kludge.
28563 32843 actiontype lastaction = action;
28564 32843 action=scrolling; FFCore.setHeroAction(scrolling);
28565
28566 // Also, hero coordinates should remain unchanged.
28567 32843 zfix storex = x, storey = y;
28568
28569
2/2
✓ Branch 0 taken 16313 times.
✓ Branch 1 taken 16530 times.
32843 if(waitdraw)
28570 {
28571 16313 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
28572 16313 }
28573 else
28574 {
28575 16530 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFCS-1);
28576 }
28577
28578
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4418 times.
✓ Branch 2 taken 4873 times.
✓ Branch 3 taken 11065 times.
✓ Branch 4 taken 12487 times.
32843 switch(scrolldir)
28579 {
28580 case up:
28581
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4290 times.
4418 if(y <= scrolling_new_region.height - 16) y = scrolling_new_region.height;
28582 128 else y = scrolling_new_region.height - 16;
28583
28584 4418 x = new_hero_x;
28585 4418 break;
28586
28587 case down:
28588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4873 times.
4873 if(y >= 0) y = -16;
28589 else y = 0;
28590
28591 4873 x = new_hero_x;
28592 4873 break;
28593
28594 case left:
28595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11065 times.
11065 if(x <= scrolling_new_region.width - 16) x = scrolling_new_region.width;
28596 else x = scrolling_new_region.width - 16;
28597
28598 11065 y = new_hero_y;
28599 11065 break;
28600
28601 case right:
28602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12487 times.
12487 if(x >= 0) x = -16;
28603 else x = 0;
28604
28605 12487 y = new_hero_y;
28606 12487 break;
28607 }
28608
28609 32843 viewport.x -= new_region_offset_x;
28610 32843 viewport.y -= new_region_offset_y;
28611
28612
4/4
✓ Branch 0 taken 21778 times.
✓ Branch 1 taken 11065 times.
✓ Branch 2 taken 12487 times.
✓ Branch 3 taken 9291 times.
32843 if (scrolldir == left || scrolldir == right)
28613 23552 x.doClamp(viewport.left(), viewport.right() - 16);
28614
4/4
✓ Branch 0 taken 28425 times.
✓ Branch 1 taken 4418 times.
✓ Branch 2 taken 4873 times.
✓ Branch 3 taken 23552 times.
32843 if (scrolldir == up || scrolldir == down)
28615 9291 y.doClamp(viewport.top(), viewport.bottom() - 16);
28616
28617 32843 run_scrolling_script_int(waitdraw);
28618
28619 32843 viewport.x += new_region_offset_x;
28620 32843 viewport.y += new_region_offset_y;
28621
28622 32843 x = storex, y = storey;
28623 32843 action=lastaction; FFCore.setHeroAction(lastaction);
28624 3267836 }
28625
28626 //Has solving the maze enabled a side warp?
28627 //Only used just before scrolling screens
28628 // Note: since scrollscr() calls this, and dowarp() calls scrollscr(),
28629 // return true to abort the topmost scrollscr() call. -L
28630 27888 bool HeroClass::maze_enabled_sizewarp(const mapscr *scr, int32_t scrolldir)
28631 {
28632 27888 maze_state.last_check_herox = x;
28633 27888 maze_state.last_check_heroy = y;
28634
28635
2/2
✓ Branch 0 taken 83664 times.
✓ Branch 1 taken 27888 times.
111552 for(int32_t i = 0; i < 3; i++) lastdir[i] = lastdir[i+1];
28636
28637
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 27620 times.
27888 lastdir[3] = scr->flags&fMAZE ? scrolldir : 0xFF;
28638
28639
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27888 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27888 if(scr->flags8&fMAZEvSIDEWARP && scr->flags&fMAZE && scrolldir != scr->exitdir)
28640 {
28641 switch(scrolldir)
28642 {
28643 case up:
28644 if(scr->flags2&wfUP && checkmaze(scr,true))
28645 {
28646 lastdir[3] = 0xFF;
28647 sdir=up;
28648 dowarp(scr,1,(scr->sidewarpindex)&3);
28649 return true;
28650 }
28651
28652 break;
28653
28654 case down:
28655 if(scr->flags2&wfDOWN && checkmaze(scr,true))
28656 {
28657 lastdir[3] = 0xFF;
28658 sdir=down;
28659 dowarp(scr,1,(scr->sidewarpindex>>2)&3);
28660 return true;
28661 }
28662
28663 break;
28664
28665 case left:
28666 if(scr->flags2&wfLEFT && checkmaze(scr,true))
28667 {
28668 lastdir[3] = 0xFF;
28669 sdir=left;
28670 dowarp(scr,1,(scr->sidewarpindex>>4)&3);
28671 return true;
28672 }
28673
28674 break;
28675
28676 case right:
28677 if(scr->flags2&wfRIGHT && checkmaze(scr,true))
28678 {
28679 lastdir[3] = 0xFF;
28680 sdir=right;
28681 dowarp(scr,1,(scr->sidewarpindex)&3);
28682 return true;
28683 }
28684
28685 break;
28686 }
28687 }
28688
28689 27888 return false;
28690 27888 }
28691
28692 27954 int32_t HeroClass::get_scroll_step(int32_t scrolldir)
28693 {
28694 // For side-scrollers, where the relative speed of 'fast' scrolling is a bit slow.
28695
2/2
✓ Branch 0 taken 2578 times.
✓ Branch 1 taken 25376 times.
27954 if(get_qr(qr_VERYFASTSCROLLING))
28696 2578 return 16;
28697
28698
2/2
✓ Branch 0 taken 23917 times.
✓ Branch 1 taken 1459 times.
25376 if(get_qr(qr_SMOOTHVERTICALSCROLLING) != 0)
28699 {
28700
2/2
✓ Branch 0 taken 15931 times.
✓ Branch 1 taken 7986 times.
23917 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
28701 }
28702 else
28703 {
28704
4/4
✓ Branch 0 taken 973 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 778 times.
1459 if(scrolldir == up || scrolldir == down)
28705 {
28706 681 return 8;
28707 }
28708 else
28709 {
28710
2/2
✓ Branch 0 taken 341 times.
✓ Branch 1 taken 437 times.
778 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 2 : 4;
28711 }
28712 }
28713 27954 }
28714
28715 27954 int32_t HeroClass::get_scroll_delay(int32_t scrolldir)
28716 {
28717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
27954 if(get_qr(qr_NOSCROLL))
28718 return 0;
28719
28720
4/4
✓ Branch 0 taken 25376 times.
✓ Branch 1 taken 2578 times.
✓ Branch 2 taken 23917 times.
✓ Branch 3 taken 1459 times.
27954 if( (get_qr(qr_VERYFASTSCROLLING) != 0) ||
28721 25376 (get_qr(qr_SMOOTHVERTICALSCROLLING) != 0) )
28722 {
28723 26495 return 1;
28724 }
28725 else
28726 {
28727
4/4
✓ Branch 0 taken 973 times.
✓ Branch 1 taken 486 times.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 778 times.
1459 if(scrolldir == up || scrolldir == down)
28728 {
28729
2/2
✓ Branch 0 taken 359 times.
✓ Branch 1 taken 322 times.
681 return (isdungeon() && !get_qr(qr_FASTDNGN)) ? 4 : 2;
28730 }
28731 else
28732 {
28733 778 return 1;
28734 }
28735 }
28736 27954 }
28737
28738 254177 void HeroClass::calc_darkroom_hero(int32_t x1, int32_t y1)
28739 {
28740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254177 times.
254177 if(!get_qr(qr_NEW_DARKROOM)) return;
28741 254177 int32_t lampid = current_item_id(itype_lantern);
28742
2/2
✓ Branch 0 taken 248624 times.
✓ Branch 1 taken 5553 times.
254177 if(lampid < 0) return;
28743
2/4
✓ Branch 0 taken 248624 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 248624 times.
248624 if(!(checkbunny(lampid) && checkmagiccost(lampid,lamp_paid)))
28744 {
28745 lamp_paid = false;
28746 return;
28747 }
28748 248624 lamp_paid = true;
28749 248624 paymagiccost(lampid,false,true);
28750
28751 248624 int32_t hx = x.getInt() - x1 + 8;
28752 248624 int32_t hy = y.getInt() - y1 + 8;
28753
28754 248624 itemdata& lamp = itemsbuf[lampid];
28755 248624 optional<word> wave_opt;
28756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248624 times.
248624 if(lamp.flags & item_flag1)
28757 wave_opt = 0; // cancel wave effect
28758 248624 handle_lighting(hx, hy, lamp.misc1, lamp.misc2, dir, darkscr_bmp, NULL, -1, -1, -1, -1, wave_opt, wave_opt);
28759 254177 }
28760
28761 struct nearby_scrolling_screen_t
28762 {
28763 int screen;
28764 int offx;
28765 int offy;
28766 bool is_new;
28767 screen_handles_t screen_handles;
28768 };
28769
28770 struct rect_t
28771 {
28772 int l, r, t, b;
28773
28774 rect_t() = default;
28775 111941 explicit rect_t(const viewport_t& viewport) : l(viewport.left()), r(viewport.right()), t(viewport.top()), b(viewport.bottom()) {}
28776
28777 42 void union_with(const rect_t& other)
28778 {
28779 42 l = std::min(l, other.l);
28780 42 r = std::max(r, other.r);
28781 42 t = std::min(t, other.t);
28782 42 b = std::max(b, other.b);
28783 42 }
28784
28785 55908 void intersect_with(const rect_t& other)
28786 {
28787 55908 l = std::max(l, other.l);
28788 55908 r = std::min(r, other.r);
28789 55908 t = std::max(t, other.t);
28790 55908 b = std::min(b, other.b);
28791
28792
2/4
✓ Branch 0 taken 55908 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 55908 times.
55908 if (l > r || t > b)
28793 l = r = t = b = 0;
28794 55908 }
28795
28796 125 bool intersects_with(const rect_t& other) const
28797 {
28798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 return std::max(t, other.t) < std::min(b, other.b) && std::max(l, other.l) < std::min(r, other.r);
28799 }
28800
28801 55908 int left() const {return l;}
28802 55908 int right() const {return r;}
28803 55908 int top() const {return t;}
28804 55908 int bottom() const {return b;}
28805 };
28806
28807 struct nearby_scrolling_screens_t
28808 {
28809 std::vector<nearby_scrolling_screen_t> screens;
28810 // Only ever true during whistle warp scrolling.
28811 bool has_overlapping_screens;
28812 rect_t old_screens_rect;
28813 rect_t new_screens_rect;
28814 };
28815
28816 // Returns all the screens (old and new region) that need to be rendered during scrolling, along
28817 // with thier draw offsets.
28818 // Note: The destination screen is Hero.current_screen, the starting screen is scrolling_hero_screen.
28819 // old_viewport_start: the viewport in the old region at start of scrolling
28820 // new_viewport_final: the viewport in the new region at end of scrolling
28821 // old_region_visible: the viewport in the old region that will be visible
28822 // new_region_visible: the viewport in the new region that will be visible
28823 27954 static nearby_scrolling_screens_t get_nearby_scrolling_screens(const std::vector<mapscr*>& old_temporary_screens, viewport_t old_viewport_start, viewport_t new_viewport_final, rect_t old_region_visible, rect_t new_region_visible)
28824 {
28825 27954 bool is_whistle_warp_scroll = HeroInOutgoingWhistleWarp();
28826 27954 int old_region = get_region_id(scrolling_map, scrolling_hero_screen);
28827
28828 27954 nearby_scrolling_screens_t nearby_screens{};
28829 27954 nearby_screens.has_overlapping_screens = is_whistle_warp_scroll;
28830
28831 // base_scr, use_new_screens, offx, offy
28832 27954 std::vector<std::tuple<mapscr*, bool, int, int>> old_screen_deltas;
28833 27954 std::vector<std::tuple<mapscr*, bool, int, int>> new_screen_deltas;
28834
28835
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int old_screens_x0 = std::clamp(old_region_visible.left() / 256, 0, 15);
28836
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int old_screens_x1 = std::clamp((old_region_visible.right() - 1) / 256, 0, 15);
28837
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int old_screens_y0 = std::clamp(old_region_visible.top() / 176, 0, 8);
28838
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int old_screens_y1 = std::clamp((old_region_visible.bottom() - 1) / 176, 0, 8);
28839
2/2
✓ Branch 0 taken 27980 times.
✓ Branch 1 taken 27954 times.
55934 for (int x = old_screens_x0; x <= old_screens_x1; x++)
28840 {
28841
2/2
✓ Branch 0 taken 28136 times.
✓ Branch 1 taken 27980 times.
56116 for (int y = old_screens_y0; y <= old_screens_y1; y++)
28842 {
28843 28136 int screen = scrolling_region.origin_screen + x + y*16;
28844
2/4
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28136 times.
28136 if (get_region_id(scrolling_map, screen) != old_region)
28845 continue;
28846
28847 28136 mapscr* base_scr = old_temporary_screens[screen*7];
28848
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28136 CHECK(base_scr);
28849 28136 bool use_new_screens = false;
28850 28136 int offx = get_region_relative_dx(screen, scrolling_region.origin_screen) * 256;
28851 28136 int offy = get_region_relative_dy(screen, scrolling_region.origin_screen) * 176;
28852
1/2
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
28136 old_screen_deltas.push_back({base_scr, use_new_screens, offx, offy});
28853 28136 }
28854 27980 }
28855
28856 // This translates from the new region to the old region's coordinates ...
28857 int dx, dy;
28858
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 27829 times.
27954 if (is_whistle_warp_scroll)
28859 {
28860 // ... anchored at the current viewport.
28861
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if (scrolling_dir == right)
28862
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 dx = old_viewport_start.right() - new_viewport_final.right();
28863 else
28864
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 dx = old_viewport_start.left() - new_viewport_final.left();
28865
28866
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 119 times.
125 if (scrolling_dir == up)
28867
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 dy = old_viewport_start.bottom() - new_viewport_final.bottom();
28868 else
28869
2/4
✓ Branch 0 taken 119 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 119 times.
✗ Branch 3 not taken.
119 dy = old_viewport_start.top() - new_viewport_final.top();
28870
28871
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 6 times.
125 if (scrolling_dir == up) dy -= old_viewport_start.h;
28872
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 115 times.
119 else if (scrolling_dir == down) dy += old_viewport_start.h;
28873
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 113 times.
115 else if (scrolling_dir == left) dx -= old_viewport_start.w;
28874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 else if (scrolling_dir == right) dx += old_viewport_start.w;
28875 125 }
28876 else
28877 {
28878 // ... anchored at the point where the screen scrolling starts.
28879 55658 dx = get_region_relative_dx(cur_screen, scrolling_region.origin_screen) -
28880 27829 (get_region_relative_dx(Hero.current_screen, scrolling_region.origin_screen) - get_region_relative_dx(scrolling_hero_screen, scrolling_region.origin_screen));
28881 55658 dy = get_region_relative_dy(cur_screen, scrolling_region.origin_screen) -
28882 27829 (get_region_relative_dy(Hero.current_screen, scrolling_region.origin_screen) - get_region_relative_dy(scrolling_hero_screen, scrolling_region.origin_screen));
28883
2/2
✓ Branch 0 taken 19757 times.
✓ Branch 1 taken 8072 times.
27829 if (scrolling_dir == up) dy -= 1;
28884
2/2
✓ Branch 0 taken 5951 times.
✓ Branch 1 taken 13806 times.
19757 else if (scrolling_dir == down) dy += 1;
28885
2/2
✓ Branch 0 taken 6518 times.
✓ Branch 1 taken 7288 times.
13806 else if (scrolling_dir == left) dx -= 1;
28886
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7288 times.
7288 else if (scrolling_dir == right) dx += 1;
28887 27829 dx *= 256;
28888 27829 dy *= 176;
28889 }
28890
28891
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int new_screens_x0 = std::clamp(new_region_visible.left() / 256, 0, 15);
28892
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int new_screens_x1 = std::clamp((new_region_visible.right() - 1) / 256, 0, 15);
28893
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int new_screens_y0 = std::clamp(new_region_visible.top() / 176, 0, 8);
28894
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 int new_screens_y1 = std::clamp((new_region_visible.bottom() - 1) / 176, 0, 8);
28895
28896
2/2
✓ Branch 0 taken 27982 times.
✓ Branch 1 taken 27954 times.
55936 for (int x = new_screens_x0; x <= new_screens_x1; x++)
28897 {
28898
2/2
✓ Branch 0 taken 28136 times.
✓ Branch 1 taken 27982 times.
56118 for (int y = new_screens_y0; y <= new_screens_y1; y++)
28899 {
28900 28136 int screen = cur_screen + x + y*16;
28901
2/4
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28136 times.
✗ Branch 3 not taken.
28136 if (!is_in_current_region(screen))
28902 continue;
28903
28904 28136 int sx = get_region_relative_dx(screen, cur_screen);
28905 28136 int sy = get_region_relative_dy(screen, cur_screen);
28906 28136 int offx = sx * 256 + dx;
28907 28136 int offy = sy * 176 + dy;
28908
28909
1/2
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
28136 mapscr* base_scr = get_scr(cur_map, screen);
28910 28136 bool use_new_screens = true;
28911
1/2
✓ Branch 0 taken 28136 times.
✗ Branch 1 not taken.
28136 new_screen_deltas.push_back({base_scr, use_new_screens, offx, offy});
28912 28136 }
28913 27982 }
28914
28915 // First handle the old screens, then the new screens.
28916 27954 std::vector<std::tuple<mapscr*, bool, int, int>> screen_deltas;
28917
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 screen_deltas.insert(screen_deltas.end(), old_screen_deltas.begin(), old_screen_deltas.end());
28918
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 screen_deltas.insert(screen_deltas.end(), new_screen_deltas.begin(), new_screen_deltas.end());
28919
28920
2/2
✓ Branch 0 taken 56272 times.
✓ Branch 1 taken 27954 times.
84226 for (const auto& pair : screen_deltas)
28921 {
28922 56272 mapscr* base_scr = std::get<0>(pair);
28923 56272 bool use_new_screens = std::get<1>(pair);
28924 56272 int offx = std::get<2>(pair);
28925 56272 int offy = std::get<3>(pair);
28926
28927 56272 int screen = base_scr->screen;
28928 56272 int map = base_scr->map;
28929
28930
1/2
✓ Branch 0 taken 56272 times.
✗ Branch 1 not taken.
56272 auto& nearby_screen = nearby_screens.screens.emplace_back();
28931 56272 nearby_screen.screen = screen;
28932 56272 nearby_screen.offx = offx;
28933 56272 nearby_screen.offy = offy;
28934 56272 nearby_screen.is_new = use_new_screens;
28935
28936 56272 nearby_screen.screen_handles[0] = {base_scr, base_scr, screen, 0};
28937
2/2
✓ Branch 0 taken 337632 times.
✓ Branch 1 taken 56272 times.
393904 for (int i = 1; i <= 6; i++)
28938 {
28939
2/2
✓ Branch 0 taken 168816 times.
✓ Branch 1 taken 168816 times.
506448 mapscr* scr = use_new_screens ?
28940
1/2
✓ Branch 0 taken 168816 times.
✗ Branch 1 not taken.
168816 get_scr_layer(map, screen, i) :
28941 168816 old_temporary_screens[screen*7 + i];
28942
2/2
✓ Branch 0 taken 67989 times.
✓ Branch 1 taken 269643 times.
337632 nearby_screen.screen_handles[i] = {base_scr, scr->is_valid() ? scr : nullptr, screen, i};
28943 337632 }
28944 }
28945
28946 // When old/new screens are possibly overlapping, reduce the drawing clip used for new screens based on the old viewport.
28947
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 27829 times.
27954 if (nearby_screens.has_overlapping_screens)
28948 {
28949
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 rect_t old_rect = rect_t(old_viewport_start);
28950
28951 125 std::vector<rect_t> new_rects;
28952
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 342 times.
467 for (const auto& nearby_screen : nearby_screens.screens)
28953 {
28954
2/2
✓ Branch 0 taken 167 times.
✓ Branch 1 taken 175 times.
342 if (!nearby_screen.is_new)
28955 175 continue;
28956
28957 rect_t rect;
28958 167 rect.l = nearby_screen.offx;
28959 167 rect.r = nearby_screen.offx + 256;
28960 167 rect.t = nearby_screen.offy;
28961 167 rect.b = nearby_screen.offy + 176;
28962
1/2
✓ Branch 0 taken 167 times.
✗ Branch 1 not taken.
167 new_rects.push_back(rect);
28963 }
28964
28965
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 rect_t new_rect = new_rects.at(0);
28966
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 42 times.
167 for (int i = 1; i < new_rects.size(); i++)
28967
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 new_rect.union_with(new_rects[i]);
28968
28969
3/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 14 times.
125 if (new_rect.intersects_with(old_rect))
28970 {
28971
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
14 if (scrolling_dir == right && new_rect.l < old_rect.r)
28972 2 new_rect.l = old_rect.r + 1;
28973
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
12 else if (scrolling_dir == left && new_rect.r > old_rect.l)
28974 2 new_rect.r = old_rect.l - 1;
28975
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
10 else if (scrolling_dir == up && new_rect.b > old_rect.t)
28976 6 new_rect.b = old_rect.t - 1;
28977
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 else if (scrolling_dir == down && new_rect.t < old_rect.b)
28978 4 new_rect.t = old_rect.b + 1;
28979 14 }
28980
28981 125 nearby_screens.old_screens_rect = old_rect;
28982 125 nearby_screens.new_screens_rect = new_rect;
28983 125 }
28984
28985 27954 return nearby_screens;
28986
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 }
28987
28988 24821514 static void for_every_nearby_screen_during_scroll(
28989 const nearby_scrolling_screens_t& nearby_screens,
28990 const std::function <void (screen_handles_t, int, int, int, bool)>& fn)
28991 {
28992
2/2
✓ Branch 0 taken 129282 times.
✓ Branch 1 taken 24692232 times.
24821514 if (!nearby_screens.has_overlapping_screens)
28993 {
28994
2/2
✓ Branch 0 taken 49849496 times.
✓ Branch 1 taken 24692232 times.
74541728 for (const auto& nearby_screen : nearby_screens.screens)
28995 49849496 fn(nearby_screen.screen_handles, nearby_screen.screen, nearby_screen.offx, nearby_screen.offy, nearby_screen.is_new);
28996 24692232 return;
28997 }
28998
28999 129282 int cl = framebuf->cl;
29000 129282 int cr = framebuf->cr;
29001 129282 int ct = framebuf->ct;
29002 129282 int cb = framebuf->cb;
29003
29004
2/2
✓ Branch 0 taken 129282 times.
✓ Branch 1 taken 395460 times.
524742 for (const auto& nearby_screen : nearby_screens.screens)
29005 {
29006
2/2
✓ Branch 0 taken 191742 times.
✓ Branch 1 taken 203718 times.
395460 auto& rect = nearby_screen.is_new ? nearby_screens.new_screens_rect : nearby_screens.old_screens_rect;
29007 395460 int l = rect.l - viewport.x;
29008 395460 int t = rect.t - viewport.y + playing_field_offset;
29009 395460 int r = rect.r - viewport.x;
29010 395460 int b = rect.b - viewport.y + playing_field_offset;
29011 395460 add_clip_rect(framebuf, l, t, r, b);
29012
29013 395460 fn(nearby_screen.screen_handles, nearby_screen.screen, nearby_screen.offx, nearby_screen.offy, nearby_screen.is_new);
29014
29015 395460 set_clip_rect(framebuf, cl, ct, cr, cb);
29016 }
29017 24821514 }
29018
29019 10406 static void scrollscr_handle_dark(mapscr* newscr, mapscr* oldscr, const nearby_scrolling_screens_t& nearby_screens)
29020 {
29021 extern int dither_offx;
29022 extern int dither_offy;
29023
29024 10406 clear_darkroom_bitmaps();
29025 10406 set_clip_rect(framebuf, 0, playing_field_offset, 256, framebuf->h);
29026
29027
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
32542 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29028 22136 mapscr* base_scr = screen_handles[0].scr;
29029
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 bool dark = is_new_screen ? is_dark(base_scr) : scrolling_is_dark(base_scr);
29030
2/2
✓ Branch 0 taken 18904 times.
✓ Branch 1 taken 3232 times.
22136 if (!dark)
29031 {
29032 3232 offy += playing_field_offset;
29033 3232 rectfill(darkscr_bmp, offx - viewport.x, offy - viewport.y, offx - viewport.x + 256 - 1, offy - viewport.y + 176 - 1, 0);
29034 3232 rectfill(darkscr_bmp_trans, offx - viewport.x, offy - viewport.y, offx - viewport.x + 256 - 1, offy - viewport.y + 176 - 1, 0);
29035 3232 }
29036 22136 });
29037
29038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10406 times.
32542 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29039 22136 mapscr* base_scr = screen_handles[0].scr;
29040
29041
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 dither_offx = is_new_screen ? -new_region_offset_x : 0;
29042
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 dither_offy = is_new_screen ? -new_region_offset_y : 0;
29043 22136 calc_darkroom_combos(base_scr, offx, offy + playing_field_offset);
29044
29045
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 int offx2 = is_new_screen ? new_region_offset_x : 0;
29046
2/2
✓ Branch 0 taken 11046 times.
✓ Branch 1 taken 11090 times.
22136 int offy2 = is_new_screen ? new_region_offset_y : 0;
29047 22136 calc_darkroom_ffcs(base_scr, offx2, offy2 + playing_field_offset);
29048 22136 });
29049
29050 10406 Hero.calc_darkroom_hero(0, -playing_field_offset);
29051 10406 dither_offx = 0;
29052 10406 dither_offy = 0;
29053
29054 10406 do_primitives(framebuf, SPLAYER_DARKROOM_UNDER);
29055 10406 set_clip_rect(framebuf, 0, playing_field_offset, framebuf->w, framebuf->h);
29056
1/2
✓ Branch 0 taken 10406 times.
✗ Branch 1 not taken.
10406 if (hero_scr->flags9 & fDARK_DITHER) //dither the entire bitmap
29057 {
29058 ditherblit(darkscr_bmp,darkscr_bmp,0,game->get_dither_type(),game->get_dither_arg());
29059 ditherblit(darkscr_bmp_trans,darkscr_bmp_trans,0,game->get_dither_type(),game->get_dither_arg());
29060 }
29061
29062 10406 color_map = &trans_table2;
29063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10406 times.
10406 if(hero_scr->flags9 & fDARK_TRANS) //draw the dark as transparent
29064 {
29065 draw_trans_sprite(framebuf, darkscr_bmp, 0, 0);
29066 if(get_qr(qr_NEWDARK_TRANS_STACKING))
29067 draw_trans_sprite(framebuf, darkscr_bmp_trans, 0, 0);
29068 }
29069 else
29070 {
29071 10406 masked_blit(darkscr_bmp, framebuf, 0, 0, 0, 0, framebuf->w, framebuf->h);
29072 10406 draw_trans_sprite(framebuf, darkscr_bmp_trans, 0, 0);
29073 }
29074 10406 color_map = &trans_table;
29075
29076 10406 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
29077 10406 do_primitives(framebuf, SPLAYER_DARKROOM_OVER);
29078 10406 }
29079
29080 17954783 static void do_ffc_scroll_layer(BITMAP* dest, int layer, const nearby_scrolling_screens_t& nearby_screens, int xoff, int yoff)
29081 {
29082
2/2
✓ Branch 0 taken 12779789 times.
✓ Branch 1 taken 5174994 times.
17954783 if(!get_qr(qr_FFCSCROLL))
29083 12779789 return;
29084 // Draw all FFCs from the previous region.
29085
2/2
✓ Branch 0 taken 703799184 times.
✓ Branch 1 taken 5174994 times.
708974178 for (int i = 0; i < FFCore.ScrollingScreensAll.size(); i += 7)
29086 {
29087 703799184 mapscr* scr = FFCore.ScrollingScreensAll[i];
29088
2/2
✓ Branch 0 taken 5763582 times.
✓ Branch 1 taken 698035602 times.
703799184 if (!scr)
29089 698035602 continue;
29090
29091 5763582 auto screen_handle = screen_handle_t{scr, scr, scr->screen, 0};
29092 5763582 do_ffc_layer(dest, layer, screen_handle, 0, 0);
29093 5763582 }
29094
29095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5174994 times.
15811246 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29096
2/2
✓ Branch 0 taken 5320392 times.
✓ Branch 1 taken 5315860 times.
10636252 if (!is_new_screen)
29097 5320392 return;
29098
29099 5315860 do_ffc_layer(dest, layer, screen_handles[0], xoff, yoff);
29100 10636252 });
29101 17954783 }
29102
29103 27954 void HeroClass::scrollscr(int32_t scrolldir, int32_t dest_screen, int32_t destdmap)
29104 {
29105
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27954 times.
27954 if(action==freeze||action==sideswimfreeze)
29106 {
29107 return;
29108 }
29109
29110 // If on a slope in sideview mode, move along that slope a bit.
29111 27954 zfix sideview_scrolling_slope;
29112
2/2
✓ Branch 0 taken 27051 times.
✓ Branch 1 taken 903 times.
27954 if (sideview_mode())
29113 {
29114 903 y+=2+0.0001_zf;
29115 903 slope_info const& s = get_slope(this, true).get_info();
29116 903 y-=2+0.0001_zf;
29117
29118 903 sideview_scrolling_slope = s.slope();
29119
1/2
✓ Branch 0 taken 903 times.
✗ Branch 1 not taken.
903 if (sideview_scrolling_slope)
29120 {
29121 int dx = 0;
29122 int dy = 0;
29123 if (scrolldir == left)
29124 dx = -1;
29125 else if (scrolldir == right)
29126 dx = 1;
29127 else if (scrolldir == up)
29128 dy = -1;
29129 else if (scrolldir == down)
29130 dy = 1;
29131
29132 // "Ride" the slope for 16 pixels.
29133 for (int i = 0; i < 16; i++)
29134 {
29135 if (scrolldir == left || scrolldir == right)
29136 {
29137 x += dx;
29138 y = s.getY(x + (sideview_scrolling_slope > 0 ? 0 : hit_width)) - hit_height;
29139 }
29140 else
29141 {
29142 x += 1 / sideview_scrolling_slope * dy;
29143 y = s.getY(x + (sideview_scrolling_slope > 0 ? 0 : hit_width)) - hit_height;
29144 }
29145
29146 herostep();
29147 draw_screen();
29148 advanceframe(true);
29149
29150 // Check if the slope the player is on has changed.
29151 y+=2+0.0001_zf;
29152 slope_info const& s = get_slope(this, true).get_info();
29153 y-=2+0.0001_zf;
29154 sideview_scrolling_slope = s.slope();
29155 if (!sideview_scrolling_slope)
29156 break;
29157 }
29158 }
29159 903 }
29160
29161
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27954 times.
27954 if (viewport_mode != ViewportMode::CenterAndBound || get_viewport_sprite() != &Hero)
29162 {
29163 set_viewport_sprite(&Hero);
29164 viewport_mode = ViewportMode::CenterAndBound;
29165 update_viewport();
29166 }
29167
29168 27954 bool overlay = false;
29169
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27954 times.
27954 if(scrolldir >= 0 && scrolldir <= 3)
29170 {
29171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
27954 overlay = get_bit(&(cur_screen >= 128 ? special_warp_return_scr : origin_scr)->sidewarpoverlayflags, scrolldir) ? true : false;
29172 27954 }
29173
29174 27954 int old_dmap = cur_dmap;
29175
2/2
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 26926 times.
27954 int new_dmap = destdmap >= 0 ? destdmap : cur_dmap;
29176 27954 int new_map = DMaps[new_dmap].map;
29177
29178 27954 bool updatemusic = FFCore.can_dmap_change_music(destdmap);
29179 27954 bool musicrevert = FFCore.music_update_flags & MUSIC_UPDATE_FLAG_REVERT;
29180
29181
3/4
✓ Branch 0 taken 27842 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 27842 times.
✗ Branch 3 not taken.
27954 if (!has_advanced_maze(origin_scr) && maze_enabled_sizewarp(origin_scr, scrolldir))
29182 return; // dowarp() was called
29183
29184 27954 int original_destscr = dest_screen;
29185
2/2
✓ Branch 0 taken 1030 times.
✓ Branch 1 taken 26924 times.
27954 if (dest_screen == -1)
29186 {
29187 26924 dest_screen = current_screen;
29188
3/4
✓ Branch 0 taken 26765 times.
✓ Branch 1 taken 159 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26765 times.
26924 if (checkmaze(origin_scr, false) && !edge_of_dmap(scrolldir)) {
29189 26765 dest_screen = screen_index_direction(dest_screen, (direction)scrolldir);
29190 26765 }
29191 26924 }
29192
29193 27954 int old_region_scr_dx = region_scr_dx;
29194 27954 int old_region_scr_dy = region_scr_dy;
29195 27954 int old_world_w = world_w;
29196 27954 int old_world_h = world_h;
29197 27954 int old_original_playing_field_offset = original_playing_field_offset;
29198 27954 viewport_t old_viewport = viewport;
29199 27954 region_t old_region = cur_region;
29200
29201 // Determine what the player position will be after scrolling (within the new screen's coordinate system),
29202 // and what the new viewport will be.
29203 viewport_t new_viewport;
29204 region_t new_region;
29205 int new_scr_dx, new_scr_dy;
29206 56294 auto calc_new_viewport_and_pos = [&](){
29207 28340 calculate_region(new_map, dest_screen, new_region, new_scr_dx, new_scr_dy);
29208
29209 // These mark the top-left coordinate of the new region, in the old region's world coordinates.
29210 28340 new_region_offset_x = (new_region.origin_screen_x - old_region.origin_screen_x)*256;
29211 28340 new_region_offset_y = (new_region.origin_screen_y - old_region.origin_screen_y)*176;
29212
29213 28340 new_hero_x = 0;
29214 28340 new_hero_y = 0;
29215
4/5
✓ Branch 0 taken 6067 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8302 times.
✓ Branch 3 taken 6540 times.
✓ Branch 4 taken 7431 times.
28340 switch (scrolldir)
29216 {
29217 case up:
29218 {
29219 8302 new_hero_x.val = (new_scr_dx - old_region_scr_dx) * 256 * 10000L + x.val;
29220 8302 new_hero_y = new_region.height - 16;
29221 }
29222 8302 break;
29223
29224 case down:
29225 {
29226 6067 new_hero_x.val = (new_scr_dx - old_region_scr_dx) * 256 * 10000L + x.val;
29227 6067 new_hero_y = 0;
29228 }
29229 6067 break;
29230
29231 case left:
29232 {
29233 6540 new_hero_x = new_region.width - 16;
29234 6540 new_hero_y.val = (new_scr_dy - old_region_scr_dy) * 176 * 10000L + y.val;
29235 }
29236 6540 break;
29237
29238 case right:
29239 {
29240 7431 new_hero_x = 0;
29241 7431 new_hero_y.val = (new_scr_dy - old_region_scr_dy) * 176 * 10000L + y.val;
29242 }
29243 7431 break;
29244
29245 // Should never happen ...
29246 default:
29247 {
29248 abort();
29249 }
29250 }
29251
29252 28340 int new_hero_x_for_viewport = new_hero_x;
29253 28340 int new_hero_y_for_viewport = new_hero_y;
29254
29255 // If arriving in a whistle warp, the new viewport will be based on the warp destination instead.
29256
2/2
✓ Branch 0 taken 28215 times.
✓ Branch 1 taken 125 times.
28340 if (HeroInOutgoingWhistleWarp())
29257 {
29258 125 const mapscr* newscr = get_canonical_scr(new_map, dest_screen);
29259
29260
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 83 times.
125 if(get_qr(qr_NOARRIVALPOINT))
29261 42 new_hero_x_for_viewport=newscr->warpreturnx[0];
29262 83 else new_hero_x_for_viewport=newscr->warparrivalx;
29263 125 new_hero_x_for_viewport += new_scr_dx*256;
29264
29265
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 83 times.
125 if(get_qr(qr_NOARRIVALPOINT))
29266 42 new_hero_y_for_viewport=newscr->warpreturny[0];
29267 83 else new_hero_y_for_viewport=newscr->warparrivaly;
29268 125 new_hero_y_for_viewport += new_scr_dy*176;
29269 125 }
29270
29271 28340 new_viewport = {};
29272 28340 calculate_viewport(new_viewport, new_dmap, dest_screen, new_region.width, new_region.height, new_hero_x_for_viewport + Hero.txsz*16/2, new_hero_y_for_viewport + Hero.tysz*16/2);
29273
29274 28340 scrolling_new_region = new_region;
29275 28340 };
29276 27954 calc_new_viewport_and_pos();
29277
29278 27954 int step = get_scroll_step(scrolldir);
29279 27954 int delay = get_scroll_delay(scrolldir);
29280
29281 int scroll_counter, scroll_amount, dx, dy;
29282 int secondary_axis_alignment_amount;
29283 56101 auto calc_scroll_data = [&](){
29284 28147 int scroll_height = std::min(viewport.h, new_viewport.h);
29285 28147 int scroll_width = std::min(viewport.w, new_viewport.w);
29286
4/4
✓ Branch 0 taken 19957 times.
✓ Branch 1 taken 8190 times.
✓ Branch 2 taken 6011 times.
✓ Branch 3 taken 13946 times.
28147 scroll_amount = scrolldir == up || scrolldir == down ? scroll_height : scroll_width;
29287 28147 scroll_counter = scroll_amount / step;
29288
29289 28147 dx = 0;
29290 28147 dy = 0;
29291
2/2
✓ Branch 0 taken 19957 times.
✓ Branch 1 taken 8190 times.
28147 if (scrolldir == up) dy = -1;
29292
2/2
✓ Branch 0 taken 22136 times.
✓ Branch 1 taken 6011 times.
28147 if (scrolldir == down) dy = 1;
29293
2/2
✓ Branch 0 taken 21617 times.
✓ Branch 1 taken 6530 times.
28147 if (scrolldir == left) dx = -1;
29294
2/2
✓ Branch 0 taken 20731 times.
✓ Branch 1 taken 7416 times.
28147 if (scrolldir == right) dx = 1;
29295
29296 // Determine by how much we need to align to the new region's viewport.
29297 // This sets `secondary_axis_alignment_amount` to the number of pixels needed to adjust along the secondary axis
29298 // to move (the position of link relative to the display) from the old viewport to the new viewport.
29299 28147 int old_hero_screen_x = x.getInt() - old_viewport.x;
29300 28147 int old_hero_screen_y = y.getInt() - old_viewport.y + old_original_playing_field_offset;
29301 28147 int new_hero_screen_x = new_hero_x - new_viewport.x;
29302 28147 int new_hero_screen_y = new_hero_y - new_viewport.y + (232 - new_viewport.h);
29303
2/2
✓ Branch 0 taken 13946 times.
✓ Branch 1 taken 14201 times.
28147 if (dx) secondary_axis_alignment_amount = new_hero_screen_y - old_hero_screen_y;
29304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14201 times.
14201 else if (dy) secondary_axis_alignment_amount = new_hero_screen_x - old_hero_screen_x;
29305 else secondary_axis_alignment_amount = 0;
29306
29307
2/2
✓ Branch 0 taken 28022 times.
✓ Branch 1 taken 125 times.
28147 if (HeroInOutgoingWhistleWarp()) secondary_axis_alignment_amount = 0;
29308 28147 };
29309 27954 calc_scroll_data();
29310
29311
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27954 bool isForceFaceUp = getOnSideviewLadder() && canSideviewLadder() &&
29312 !(jumping<0 || fall!=0 || fakefall!=0) && get_qr(qr_SIDEVIEWLADDER_FACEUP);
29313
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 if (isForceFaceUp) dir = up;
29314
29315 27954 bool is_unsmooth_vertical_scrolling =
29316
4/4
✓ Branch 0 taken 19876 times.
✓ Branch 1 taken 8078 times.
✓ Branch 2 taken 5955 times.
✓ Branch 3 taken 13921 times.
27954 (scrolldir == up || scrolldir == down) && get_qr(qr_SMOOTHVERTICALSCROLLING) == 0;
29317
29318 27954 kill_enemy_sfx();
29319 27954 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
29320 27954 FFCore.ScrollingData[SCROLLDATA_DIR] = scrolldir;
29321
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 8078 times.
✓ Branch 2 taken 5955 times.
✓ Branch 3 taken 6520 times.
✓ Branch 4 taken 7401 times.
27954 switch(scrolldir)
29322 {
29323 case up:
29324 8078 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
29325 8078 FFCore.ScrollingData[SCROLLDATA_NY] = -176;
29326 8078 break;
29327 case down:
29328 5955 FFCore.ScrollingData[SCROLLDATA_NX] = 0;
29329 5955 FFCore.ScrollingData[SCROLLDATA_NY] = 176;
29330 5955 break;
29331 case left:
29332 6520 FFCore.ScrollingData[SCROLLDATA_NX] = -256;
29333 6520 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
29334 6520 break;
29335 case right:
29336 7401 FFCore.ScrollingData[SCROLLDATA_NX] = 256;
29337 7401 FFCore.ScrollingData[SCROLLDATA_NY] = 0;
29338 7401 break;
29339 }
29340 27954 FFCore.ScrollingData[SCROLLDATA_NEW_REGION_DELTA_X] = new_region_offset_x;
29341 27954 FFCore.ScrollingData[SCROLLDATA_NEW_REGION_DELTA_Y] = new_region_offset_y;
29342 27954 FFCore.ScrollingData[SCROLLDATA_NRX] = new_region_offset_x - viewport.x;
29343 27954 FFCore.ScrollingData[SCROLLDATA_NRY] = new_region_offset_y - viewport.y;
29344 27954 FFCore.ScrollingData[SCROLLDATA_ORX] = -viewport.x;
29345 27954 FFCore.ScrollingData[SCROLLDATA_ORY] = -viewport.y;
29346
29347 // Get the screen coords of the top-left of the screen we are scrolling away from.
29348 111816 auto [old_sx, old_sy] = translate_screen_coordinates_to_world(current_screen);
29349 27954 FFCore.ScrollingData[SCROLLDATA_OX] = old_sx - viewport.x;
29350 27954 FFCore.ScrollingData[SCROLLDATA_OY] = old_sy - viewport.y;
29351
29352 27954 FFCore.ScrollingData[SCROLLDATA_NEW_SCREEN_X] = new_scr_dx * 256;
29353 27954 FFCore.ScrollingData[SCROLLDATA_NEW_SCREEN_Y] = new_scr_dy * 176;
29354
29355 27954 FFCore.ScrollingData[SCROLLDATA_OLD_SCREEN_X] = old_sx;
29356 27954 FFCore.ScrollingData[SCROLLDATA_OLD_SCREEN_Y] = old_sy;
29357
29358 27954 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_X] = new_hero_x.getInt();
29359 27954 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_Y] = new_hero_y.getInt();
29360
29361 27954 FFCore.ScrollingData[SCROLLDATA_OLD_HERO_X] = x.getInt();
29362 27954 FFCore.ScrollingData[SCROLLDATA_OLD_HERO_Y] = y.getInt();
29363
29364 27954 FFCore.ScrollingData[SCROLLDATA_NEW_REGION_SCREEN_WIDTH] = new_region.screen_width;
29365 27954 FFCore.ScrollingData[SCROLLDATA_NEW_REGION_SCREEN_HEIGHT] = new_region.screen_height;
29366
29367 27954 FFCore.ScrollingData[SCROLLDATA_OLD_REGION_SCREEN_WIDTH] = cur_region.screen_width;
29368 27954 FFCore.ScrollingData[SCROLLDATA_OLD_REGION_SCREEN_HEIGHT] = cur_region.screen_height;
29369
29370 27954 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_WIDTH] = new_viewport.w;
29371 27954 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_HEIGHT] = new_viewport.h;
29372
29373 27954 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_WIDTH] = viewport.w;
29374 27954 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_HEIGHT] = viewport.h;
29375
29376 27954 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_X] = new_viewport.x;
29377 27954 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_Y] = new_viewport.y;
29378
29379 27954 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_X] = viewport.x;
29380 27954 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_Y] = viewport.y;
29381
29382 27954 FFCore.clear_combo_scripts();
29383
29384 27954 conveyclk = 2;
29385 27954 screenscrolling = true;
29386 27954 scrolling_dir = (direction) scrolldir;
29387 27954 scrolling_hero_screen = current_screen;
29388 27954 scrolling_region = cur_region;
29389 27954 scrolling_region_is_lit = region_is_lit;
29390
29391 27954 int32_t scx = get_qr(qr_FASTDNGN) ? 30 : 0;
29392
2/2
✓ Branch 0 taken 25376 times.
✓ Branch 1 taken 2578 times.
27954 if(get_qr(qr_VERYFASTSCROLLING)) //just a minor adjustment.
29393 2578 scx = 32; //for sideview very fast screolling.
29394
29395 27954 auto hero_x_before_scripts = x;
29396 27954 auto hero_y_before_scripts = y;
29397
29398 // Don't signal to scripts that scrolling has "started" (and thus all the Game->Scrolling variables are valid)
29399 // just yet. Store what we calculated and apply them after this next frame.
29400 // TODO(replays): update. And probably just move the calculation to after this frame renders (rather than cache).
29401
11/20
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 27946 times.
✓ Branch 2 taken 27946 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27946 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27946 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✓ Branch 9 taken 27946 times.
✓ Branch 10 taken 8 times.
✓ Branch 11 taken 27946 times.
✓ Branch 12 taken 8 times.
✓ Branch 13 taken 27946 times.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
55900 bool crucible_quest_compat = replay_is_debug() && replay_get_meta_str("qst") == "crucible_quest.qst";
29402 int cached_scrolling[SZ_SCROLLDATA];
29403
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 27734 times.
27954 if (!crucible_quest_compat)
29404 {
29405
2/2
✓ Branch 0 taken 859754 times.
✓ Branch 1 taken 27734 times.
887488 for (int i = 0; i < SZ_SCROLLDATA; i++)
29406 859754 cached_scrolling[i] = FFCore.ScrollingData[i];
29407 27734 memset(FFCore.ScrollingData, 0, sizeof(int32_t) * SZ_SCROLLDATA);
29408 27734 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
29409 27734 }
29410
29411 // Wait one frame. This still uses the old region's coordinates.
29412 27954 int32_t lastattackclk = attackclk, lastspins = spins, lastcharging = charging;
29413 27954 bool lasttapping = tapping;
29414 27954 actiontype lastaction = action;
29415 {
29416 27954 ALLOFF(false, false);
29417 // for now, restore Hero's previous action
29418
2/2
✓ Branch 0 taken 26070 times.
✓ Branch 1 taken 1884 times.
27954 if(!get_qr(qr_SCROLLING_KILLS_CHARGE))
29419 1884 charging = lastcharging;
29420
2/2
✓ Branch 0 taken 9244 times.
✓ Branch 1 taken 18710 times.
27954 if (replay_version_check(0, 28))
29421 {
29422 // nargads_trail_crystal_crusades replay tests need this.
29423
2/2
✓ Branch 0 taken 18436 times.
✓ Branch 1 taken 274 times.
18710 if(!get_qr(qr_SCROLLING_KILLS_CHARGE)) attackclk = lastattackclk;
29424 18710 spins = lastspins; charging = lastcharging; tapping = lasttapping;
29425 18710 }
29426
29427 27954 action=lastaction; FFCore.setHeroAction(lastaction);
29428
29429 27954 lstep = (lstep + 6) % 12;
29430 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_WAITDRAW);
29431
3/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18377 times.
✓ Branch 3 taken 9577 times.
27954 if((!( FFCore.system_suspend[susptGLOBALGAME] )) && FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME))
29432 {
29433 9577 ZScriptVersion::RunScript(ScriptType::Global, GLOBAL_SCRIPT_GAME, GLOBAL_SCRIPT_GAME);
29434 9577 FFCore.waitdraw(ScriptType::Global, GLOBAL_SCRIPT_GAME) = false;
29435 9577 }
29436 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_GLOBAL_WAITDRAW);
29437
5/6
✓ Branch 0 taken 27943 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1099 times.
✓ Branch 3 taken 26844 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1099 times.
27954 if ( (!( FFCore.system_suspend[susptHEROACTIVE] )) && FFCore.waitdraw(ScriptType::Hero) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
29438 {
29439 1099 ZScriptVersion::RunScript(ScriptType::Hero, SCRIPT_HERO_ACTIVE);
29440 1099 FFCore.waitdraw(ScriptType::Hero) = false;
29441 1099 }
29442 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_PLAYER_WAITDRAW);
29443
4/6
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92 times.
✓ Branch 3 taken 27862 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 92 times.
27954 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::DMap) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
29444 {
29445 92 ZScriptVersion::RunScript(ScriptType::DMap, DMaps[cur_dmap].script,cur_dmap);
29446 92 FFCore.waitdraw(ScriptType::DMap) = false;
29447 92 }
29448 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_ACTIVE_WAITDRAW);
29449
2/6
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27954 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27954 if ( (!( FFCore.system_suspend[susptDMAPSCRIPT] )) && FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && FFCore.getQuestHeaderInfo(vZelda) >= 0x255 )
29450 {
29451 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script,cur_dmap);
29452 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
29453 }
29454 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DMAPDATA_PASSIVESUBSCREEN_WAITDRAW);
29455
29456
4/4
✓ Branch 0 taken 3213 times.
✓ Branch 1 taken 24741 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 3203 times.
27954 if (FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && !FFCore.system_suspend[susptSCREENSCRIPTS])
29457 {
29458 7178 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
29459
4/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 3950 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 14 times.
3975 if (scr->script != 0 && FFCore.waitdraw(ScriptType::Screen, scr->screen))
29460 {
29461 14 ZScriptVersion::RunScript(ScriptType::Screen, scr->script, scr->screen);
29462 14 FFCore.waitdraw(ScriptType::Screen, scr->screen) = 0;
29463 14 }
29464 3975 });
29465 3203 }
29466 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_SCREEN_WAITDRAW);
29467
29468 889134 for_every_ffc([&](const ffc_handle_t& ffc_handle) {
29469
4/4
✓ Branch 0 taken 12511 times.
✓ Branch 1 taken 848669 times.
✓ Branch 2 taken 12487 times.
✓ Branch 3 taken 24 times.
861180 if (ffc_handle.ffc->script != 0 && FFCore.waitdraw(ScriptType::FFC, ffc_handle.id))
29470 {
29471 24 ZScriptVersion::RunScript(ScriptType::FFC, ffc_handle.ffc->script, ffc_handle.id);
29472 24 FFCore.waitdraw(ScriptType::FFC, ffc_handle.id) = false;
29473 24 }
29474 861180 });
29475
29476 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_FFC_WAITDRAW);
29477 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_COMBO_WAITDRAW);
29478 //Waitdraw for item scripts.
29479 27954 FFCore.itemScriptEngineOnWaitdraw();
29480 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEM_WAITDRAW);
29481 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_NPC_WAITDRAW);
29482
29483 //Sprite scripts on Waitdraw
29484 27954 FFCore.eweaponScriptEngineOnWaitdraw();
29485 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_EWPN_WAITDRAW);
29486 27954 FFCore.itemSpriteScriptEngineOnWaitdraw();
29487 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_ITEMSPRITE_WAITDRAW);
29488
29489 //This is no longer a do-while, as the first iteration is now slightly different. -Em
29490 27954 draw_screen(true,true);
29491
29492 27954 rehydratelake(false);
29493
29494 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
29495 }
29496
29497 27954 advanceframe(true);
29498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
27954 if(Quit)
29499 {
29500 screenscrolling = false;
29501 return;
29502 }
29503
29504
2/2
✓ Branch 0 taken 220 times.
✓ Branch 1 taken 27734 times.
27954 if (!crucible_quest_compat)
29505 {
29506
2/2
✓ Branch 0 taken 859754 times.
✓ Branch 1 taken 27734 times.
887488 for (int i = 0; i < SZ_SCROLLDATA; i++)
29507 859754 FFCore.ScrollingData[i] = cached_scrolling[i];
29508 27734 }
29509
29510 // cur_dmap won't change until the end of the scroll. Store new dmap in this global variable.
29511 27954 scrolling_destdmap = new_dmap;
29512
29513 // Calling functions are responsible for setting cur_map (but not cur_screen...), but before we
29514 // _actually_ start to scroll we draw a few frames of the current screen (draw_screen). So we
29515 // need cur_map to be the old value initially. Callers also set the old map value to
29516 // `scrolling_map`, so we can use that.
29517 27954 int destmap = cur_map;
29518 27954 cur_map = scrolling_map;
29519
29520 // This adjusts how drawing commands are interpreted in `do_drawing_command`.
29521 // Currently, since only one set of screen scripts/item scripts/etc. can run at a time during
29522 // scrolling (either the old screens, which was above and this next "waiting" phase, or the new
29523 // screens, which comes after this next part) - a boolean is enough to capture this. If this
29524 // changes, we need to vary this behavior based on "is this from the new or old set of screens?"
29525 27954 scrolling_using_new_region_coords = true;
29526
29527 // Wait at least one frame, possibly 32.
29528 // These frames will use the new region's coordinates.
29529 {
29530 27954 int wait_counter = scx + 1;
29531
2/2
✓ Branch 0 taken 139106 times.
✓ Branch 1 taken 27954 times.
167060 while (wait_counter < 32)
29532 {
29533
1/2
✓ Branch 0 taken 139106 times.
✗ Branch 1 not taken.
139106 if(isForceFaceUp) dir = up;
29534
2/2
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 138363 times.
139106 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
29535 {
29536 743 script_drawing_commands.Clear();
29537 743 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
29538 743 ZScriptVersion::RunScrollingScript(scrolldir, wait_counter, 0, 0, false, false); // Prewaitdraw
29539 743 ZScriptVersion::RunScrollingScript(scrolldir, wait_counter, 0, 0, false, true); // Waitdraw
29540 743 }
29541 138363 else FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
29542 139106 draw_screen(true,true);
29543
29544
1/2
✓ Branch 0 taken 139106 times.
✗ Branch 1 not taken.
139106 if (wait_counter == scx)
29545 rehydratelake(false);
29546
29547 139106 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
29548 139106 advanceframe(true);
29549
29550
1/2
✓ Branch 0 taken 139106 times.
✗ Branch 1 not taken.
139106 if(Quit)
29551 {
29552 screenscrolling = false;
29553 return;
29554 }
29555
29556 139106 ++wait_counter;
29557 }
29558 }
29559
29560 27954 script_drawing_commands.Clear();
29561 27954 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
29562
29563 // Just trying to play the sound.
29564
2/2
✓ Branch 0 taken 26924 times.
✓ Branch 1 taken 1030 times.
27954 if (original_destscr == -1)
29565 26924 checkmaze(origin_scr, true);
29566
29567
3/4
✓ Branch 0 taken 12413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6861 times.
✓ Branch 3 taken 8680 times.
27954 switch(DMaps[cur_dmap].type&dmfTYPE)
29568 {
29569 case dmDNGN:
29570
2/2
✓ Branch 0 taken 8673 times.
✓ Branch 1 taken 7 times.
8680 if(!get_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING))
29571 {
29572 7 markBmap(scrolldir, current_screen);
29573 7 }
29574 8680 break;
29575 case dmOVERW: case dmBSOVERW:
29576
2/2
✓ Branch 0 taken 12016 times.
✓ Branch 1 taken 397 times.
12413 if(get_qr(qr_NO_OVERWORLD_MAP_CHARTING))
29577 12016 break;
29578 [[fallthrough]];
29579 case dmCAVE:
29580 7258 markBmap(scrolldir, current_screen);
29581 7258 break;
29582 }
29583
29584 // Remember everything about the current region, because `loadscr` is about to reset this data.
29585 27954 std::vector<mapscr*> old_temporary_screens;
29586
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 old_temporary_screens = take_temporary_scrs();
29587
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 FFCore.ScrollingScreensAll = old_temporary_screens;
29588 27954 cur_map = destmap;
29589
29590
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 loadscr(destdmap, dest_screen, scrolldir, overlay);
29591 27954 mapscr* oldscr = old_temporary_screens[scrolling_hero_screen * 7];
29592
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 mapscr* newscr = get_scr(destmap, dest_screen);
29593
29594 // Start scrolling with the previous pfo, and adjust during scrolling if necessary.
29595 27954 int new_playing_field_offset = playing_field_offset;
29596 27954 playing_field_offset = old_original_playing_field_offset;
29597
29598 // We must recalculate the new hero position and viewport, if a script run above just change the
29599 // hero position.
29600
10/16
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27924 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 27924 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27924 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27924 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 163 times.
✓ Branch 15 taken 27761 times.
27954 if (hero_x_before_scripts != x || hero_y_before_scripts != y)
29601 {
29602
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 calc_new_viewport_and_pos();
29603
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 calc_scroll_data();
29604
29605 193 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_X] = new_viewport.x;
29606 193 FFCore.ScrollingData[SCROLLDATA_NEW_VIEWPORT_Y] = new_viewport.y;
29607
29608 193 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_X] = viewport.x;
29609 193 FFCore.ScrollingData[SCROLLDATA_OLD_VIEWPORT_Y] = viewport.y;
29610
29611
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_X] = new_hero_x.getInt();
29612
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_Y] = new_hero_y.getInt();
29613 193 }
29614
29615 // 0 for change playing field offset, then scroll.
29616 // 1 for scroll, then change playing field offset.
29617 27954 int pfo_mode = 0;
29618
29619
2/2
✓ Branch 0 taken 5955 times.
✓ Branch 1 taken 21999 times.
27954 if (dy == 1)
29620 5955 pfo_mode = 0;
29621
2/2
✓ Branch 0 taken 13921 times.
✓ Branch 1 taken 8078 times.
21999 else if (dy == -1)
29622 8078 pfo_mode = 1;
29623
5/6
✓ Branch 0 taken 13875 times.
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 13875 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13845 times.
✓ Branch 5 taken 30 times.
13921 else if (old_region_scr_dy == 0 && sign(new_playing_field_offset - old_original_playing_field_offset) == -1)
29624 30 pfo_mode = 1;
29625
29626 27954 int pfo_counter = abs(new_playing_field_offset - old_original_playing_field_offset);
29627
29628 // When scrolling up/down, and if scrolling first and the final pfo is less, reduce the scroll distance.
29629
6/6
✓ Branch 0 taken 14033 times.
✓ Branch 1 taken 13921 times.
✓ Branch 2 taken 8078 times.
✓ Branch 3 taken 5955 times.
✓ Branch 4 taken 8076 times.
✓ Branch 5 taken 2 times.
27954 if (dy && pfo_mode == 1 && new_playing_field_offset > old_original_playing_field_offset)
29630 {
29631 2 scroll_amount += new_playing_field_offset - old_original_playing_field_offset;
29632 2 scroll_counter = scroll_amount / step;
29633 2 }
29634
29635 // If adjusting pfo first and the final pfo is more, increase the scroll distance.
29636 // Also make the pfo adjust instantly.
29637
6/6
✓ Branch 0 taken 14033 times.
✓ Branch 1 taken 13921 times.
✓ Branch 2 taken 5955 times.
✓ Branch 3 taken 8078 times.
✓ Branch 4 taken 5953 times.
✓ Branch 5 taken 2 times.
27954 if (dy && pfo_mode == 0 && new_playing_field_offset < old_original_playing_field_offset)
29638 {
29639 2 scroll_amount -= new_playing_field_offset - old_original_playing_field_offset;
29640 2 scroll_counter = scroll_amount / step;
29641 2 pfo_counter = 1;
29642 2 }
29643
29644 viewport_t old_world_rect;
29645 27954 old_world_rect.x = 0;
29646 27954 old_world_rect.y = 0;
29647 27954 old_world_rect.w = old_world_w;
29648 27954 old_world_rect.h = old_world_h;
29649
29650 viewport_t new_world_rect;
29651 27954 new_world_rect.x = 0;
29652 27954 new_world_rect.y = 0;
29653 27954 new_world_rect.w = world_w;
29654 27954 new_world_rect.h = world_h;
29655
29656 // 0 for align, then scroll.
29657 // 1 for scroll, then align.
29658 27954 int align_mode = 0;
29659 27954 int align_counter = abs(secondary_axis_alignment_amount);
29660 // Align first, unless that would show screens outside the old region.
29661
2/2
✓ Branch 0 taken 27876 times.
✓ Branch 1 taken 78 times.
27954 if (align_counter)
29662 {
29663 78 viewport_t old_viewport_aligned = old_viewport;
29664
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 68 times.
78 old_viewport_aligned.x -= (dy ? secondary_axis_alignment_amount : 0);
29665
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 10 times.
78 old_viewport_aligned.y -= (dx ? secondary_axis_alignment_amount : 0);
29666 // The playing field offset is changed before aligning, so apply the delta in this check.
29667
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 50 times.
78 if (pfo_mode == 0)
29668 50 old_viewport_aligned.y += new_playing_field_offset - old_original_playing_field_offset;
29669
3/4
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 44 times.
78 if (old_world_rect.contains_or_on(old_viewport_aligned))
29670 34 align_mode = 0;
29671 else
29672 44 align_mode = 1;
29673 78 }
29674
29675 // Determine the area that will be visible in the old and the new regions,
29676 // taking into account any possible alignment. All screens within these
29677 // area will be fetched by get_nearby_scrolling_screens.
29678
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 rect_t old_region_visible = rect_t(old_viewport);
29679
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 rect_t new_region_visible = rect_t(new_viewport);
29680
2/2
✓ Branch 0 taken 27876 times.
✓ Branch 1 taken 78 times.
27954 if (secondary_axis_alignment_amount)
29681 {
29682
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 34 times.
78 rect_t& r = align_mode == 0 ? old_region_visible : new_region_visible;
29683
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 34 times.
78 int delta = align_mode == 0 ? -secondary_axis_alignment_amount : secondary_axis_alignment_amount;
29684
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 68 times.
78 if (dy)
29685 {
29686
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 if (delta > 0)
29687 8 r.r += delta;
29688 else
29689 2 r.l += delta;
29690 10 }
29691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68 times.
68 else if (dx)
29692 {
29693
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 52 times.
68 if (delta > 0)
29694 16 r.b += delta;
29695 else
29696 52 r.t += delta;
29697 68 }
29698 78 }
29699
29700
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 old_region_visible.intersect_with(rect_t(old_world_rect));
29701
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
27954 new_region_visible.intersect_with(rect_t(new_world_rect));
29702
29703 // For the duration of the scrolling, the old region coordinate system is used for all drawing
29704 // operations. This means that the new screens are drawn with offsets relative to the old
29705 // coordinate system. These offsets are determined in get_nearby_scrolling_screens.
29706
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 auto nearby_screens = get_nearby_scrolling_screens(old_temporary_screens, old_viewport, new_viewport, old_region_visible, new_region_visible);
29707
29708
2/2
✓ Branch 0 taken 6520 times.
✓ Branch 1 taken 21434 times.
27954 int sx = viewport.x + (scrolldir == left ? viewport.w : 0);
29709
2/2
✓ Branch 0 taken 19876 times.
✓ Branch 1 taken 8078 times.
27954 int sy = viewport.y + (scrolldir == up ? viewport.h : 0);
29710
2/2
✓ Branch 0 taken 27273 times.
✓ Branch 1 taken 681 times.
27954 if (is_unsmooth_vertical_scrolling) sy += 3;
29711
29712 // We must recalculate the new hero position, if a script run above just change the
29713 // hero position.
29714
8/14
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27924 times.
✓ Branch 7 taken 30 times.
✓ Branch 8 taken 27924 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27924 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27924 times.
✗ Branch 13 not taken.
27954 if (hero_x_before_scripts != x || hero_y_before_scripts != y)
29715 {
29716
2/2
✓ Branch 0 taken 193 times.
✓ Branch 1 taken 27761 times.
27954 calc_new_viewport_and_pos();
29717
29718
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_X] = new_hero_x.getInt();
29719
1/2
✓ Branch 0 taken 193 times.
✗ Branch 1 not taken.
193 FFCore.ScrollingData[SCROLLDATA_NEW_HERO_Y] = new_hero_y.getInt();
29720 193 }
29721
29722 // change Hero's state if entering water
29723
6/10
✓ Branch 0 taken 27954 times.
✓ Branch 1 taken 27761 times.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27954 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27954 times.
✗ Branch 9 not taken.
193 int32_t ahead = lookahead(scrolldir, new_hero_x, new_hero_y + 8);
29724
7/14
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27954 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27954 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27954 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27954 times.
✗ Branch 13 not taken.
27954 auto [lookaheadx, lookaheady] = lookahead_coords(scrolldir, new_hero_x + 8, new_hero_y + (bigHitbox?8:12));
29725
7/14
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27954 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27954 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27954 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27954 times.
✗ Branch 13 not taken.
82704 auto [wateraheadx1, wateraheady1] = lookahead_coords(scrolldir, new_hero_x + 4, new_hero_y + 9);
29726
7/14
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27954 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27954 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27954 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 27954 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 27954 times.
✗ Branch 13 not taken.
28714 auto [wateraheadx2, wateraheady2] = lookahead_coords(scrolldir, new_hero_x + 11, new_hero_y + 15);
29727
29728 27954 bool nowinwater = false;
29729 {
29730
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 27829 times.
27954 if(lastaction != inwind)
29731 {
29732
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 27375 times.
27829 if(lastaction == rafting ) //&& isRaftFlag(aheadflag))
29733 {
29734
5/8
✓ Branch 0 taken 454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 454 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 454 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 438 times.
✓ Branch 7 taken 16 times.
454 if (lookaheadraftflag(scrolldir, new_hero_x, new_hero_y))
29735 {
29736
1/2
✓ Branch 0 taken 438 times.
✗ Branch 1 not taken.
438 action=rafting; FFCore.setHeroAction(rafting);
29737 438 raftclk=0;
29738 438 }
29739 454 }
29740
13/20
✓ Branch 0 taken 27375 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27375 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27375 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 380 times.
✓ Branch 7 taken 26995 times.
✓ Branch 8 taken 380 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 380 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 380 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 373 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 373 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 348 times.
✓ Branch 19 taken 25 times.
82125 else if(iswaterex_z3(ahead, -1, wateraheadx1,wateraheady1) && iswaterex_z3(ahead, -1, wateraheadx2,wateraheady2) && (current_item(itype_flippers)))
29741 {
29742
9/16
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 328 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✗ Branch 15 not taken.
348 if(lastaction==swimming || lastaction == sideswimming || lastaction == sideswimattacking || lastaction == sideswimhit || lastaction == swimhit || lastaction == sideswimcasting || lastaction == sidewaterhold1 || lastaction == sidewaterhold2)
29743 {
29744
1/2
✓ Branch 0 taken 328 times.
✗ Branch 1 not taken.
328 SetSwim();
29745 328 hopclk = 0xFF;
29746 328 nowinwater = true;
29747 328 }
29748 else
29749 {
29750
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 action=hopping; FFCore.setHeroAction(hopping);
29751 20 hopclk = 2;
29752 20 nowinwater = true;
29753 }
29754 348 }
29755
4/4
✓ Branch 0 taken 26979 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 26995 times.
27027 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
29756 {
29757
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 action = lastaction; FFCore.setHeroAction(lastaction);
29758 32 }
29759 else
29760 {
29761
1/2
✓ Branch 0 taken 26995 times.
✗ Branch 1 not taken.
26995 action=none; FFCore.setHeroAction(none);
29762 }
29763 27829 }
29764
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 else if((lastaction == attacking || lastaction == sideswimattacking) && charging)
29765 {
29766 action = lastaction; FFCore.setHeroAction(lastaction);
29767 }
29768 else
29769 {
29770
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 action=none; FFCore.setHeroAction(none);
29771 }
29772
29773
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27954 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
27954 isForceFaceUp = isForceFaceUp && canSideviewLadderRemote(lookaheadx,lookaheady);
29774
29775 // The naturaldark state can be read/set by an FFC script before
29776 // fade() or lighting() is called.
29777
3/4
✓ Branch 0 taken 25737 times.
✓ Branch 1 taken 2217 times.
✓ Branch 2 taken 25737 times.
✗ Branch 3 not taken.
53691 naturaldark = !get_qr(qr_NEW_DARKROOM) && is_dark(newscr);
29778
29779
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 27652 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
27954 if(newscr->oceansfx != oldscr->oceansfx) adjust_sfx(oldscr->oceansfx, 128, false);
29780
29781
3/4
✓ Branch 0 taken 455 times.
✓ Branch 1 taken 27499 times.
✓ Branch 2 taken 455 times.
✗ Branch 3 not taken.
27954 if(newscr->bosssfx != oldscr->bosssfx) adjust_sfx(oldscr->bosssfx, 128, false);
29782
29783 //Preloaded ffc scripts
29784 {
29785 // Kludge
29786 27954 cur_dmap = new_dmap;
29787
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 ffscript_engine(true);
29788 27954 cur_dmap = old_dmap;
29789 }
29790
29791 // There are two occasions when scrolling must be darkened:
29792 // 1) When scrolling into a dark room.
29793 // 2) When scrolling between DMaps of different colours.
29794
4/4
✓ Branch 0 taken 1028 times.
✓ Branch 1 taken 26926 times.
✓ Branch 2 taken 489 times.
✓ Branch 3 taken 539 times.
27954 if(destdmap != -1 && DMaps[destdmap].color != currcset)
29795 {
29796
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✓ Branch 2 taken 539 times.
✗ Branch 3 not taken.
539 fade((specialcave > 0) ? (specialcave >= GUYCAVE) ? 10 : 11 : currcset, true, false);
29797 539 darkroom = true;
29798 539 }
29799
2/2
✓ Branch 0 taken 27161 times.
✓ Branch 1 taken 254 times.
27415 else if(!darkroom)
29800
1/2
✓ Branch 0 taken 27161 times.
✗ Branch 1 not taken.
27161 lighting(false, false); // NES behaviour: fade to dark before scrolling
29801
29802
2/2
✓ Branch 0 taken 454 times.
✓ Branch 1 taken 27500 times.
27954 if(action != rafting) // Is this supposed to be here?!
29803 27500 scroll_counter++; //This was the easiest way to re-arrange the loop so drawing is in the middle
29804 }
29805
29806 27954 bool draw_dark = false;
29807
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
84226 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29808 56272 mapscr* base_scr = screen_handles[0].scr;
29809
2/2
✓ Branch 0 taken 28136 times.
✓ Branch 1 taken 28136 times.
56272 bool dark = is_new_screen ? is_dark(base_scr) : scrolling_is_dark(base_scr);
29810 56272 draw_dark |= dark;
29811 56272 });
29812
29813 27954 int no_move = 0;
29814 27954 int move_counter = 0;
29815 27954 bool end_frames = false;
29816
29817 27954 scroll_counter *= delay;
29818
29819
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 if (get_qr(qr_NOSCROLL))
29820 {
29821 delay = 0;
29822 secondary_axis_alignment_amount = 0;
29823 pfo_counter = 0;
29824 align_counter = 0;
29825 }
29826
29827 27954 viewport_t initial_viewport = old_viewport;
29828 27954 viewport = initial_viewport;
29829
2/2
✓ Branch 0 taken 27273 times.
✓ Branch 1 taken 681 times.
27954 if (is_unsmooth_vertical_scrolling) viewport.y += 3;
29830
29831 // These mark the top-left coordinate of the new screen and the old screen, in the old region
29832 // coordinates.
29833 27954 int nx = 0;
29834 27954 int ny = 0;
29835 27954 int ox = 0;
29836 27954 int oy = 0;
29837
2/4
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27954 times.
✗ Branch 3 not taken.
84226 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
29838
4/4
✓ Branch 0 taken 28129 times.
✓ Branch 1 taken 28143 times.
✓ Branch 2 taken 175 times.
✓ Branch 3 taken 27954 times.
56272 if (screen == dest_screen && is_new_screen)
29839 {
29840 27954 nx = offx;
29841 27954 ny = offy;
29842 27954 }
29843
4/4
✓ Branch 0 taken 27960 times.
✓ Branch 1 taken 358 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 27954 times.
28318 else if (screen == scrolling_hero_screen && !is_new_screen)
29844 {
29845 27954 ox = offx;
29846 27954 oy = offy;
29847 27954 }
29848 56272 });
29849
29850 // FFCs coordinates are world positions, and so don't need an offset like when drawing a
29851 // specific screen's combos in do_scrolling_layer. But since their coordinates are in the new
29852 // region's coordinate system, an offset of the difference between the two coordinate systems is
29853 // needed.
29854 // TODO: figure out how to calculate this in calc_new_viewport_and_pos, before their first usage...
29855
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 new_region_offset_x = nx - get_region_relative_dx(dest_screen)*256;
29856
1/2
✓ Branch 0 taken 27954 times.
✗ Branch 1 not taken.
27954 new_region_offset_y = ny - get_region_relative_dy(dest_screen)*176;
29857
29858 27954 cur_dmap = new_dmap;
29859
6/6
✓ Branch 0 taken 1631482 times.
✓ Branch 1 taken 28724 times.
✓ Branch 2 taken 572 times.
✓ Branch 3 taken 28152 times.
✓ Branch 4 taken 27950 times.
✓ Branch 5 taken 1632256 times.
1660206 for (int i = 0; (scroll_counter >= 0 && delay != 0) || align_counter || pfo_counter; i++, scroll_counter--)
29860 {
29861 // Scripts see the hero position as if relative to the scrolling viewport. This is a weird
29862 // quirk that should probably be placed behind a compat QR.
29863
2/4
✓ Branch 0 taken 1632256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632256 times.
✗ Branch 3 not taken.
1632256 zfix prev_x, prev_y;
29864 #define SAVE_HERO_POS {prev_x = x; prev_y = y;}
29865 #define USE_COMPAT_HERO_POS {x -= viewport.x; y -= viewport.y;}
29866 #define RESTORE_HERO_POS {x = prev_x; y = prev_y;}
29867
29868
3/4
✓ Branch 0 taken 1632256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159376 times.
✓ Branch 3 taken 1472880 times.
1632256 if (replay_version_check(0, 3))
29869 {
29870
1/2
✓ Branch 0 taken 159376 times.
✗ Branch 1 not taken.
159376 replay_poll();
29871 159376 }
29872
29873
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1632253 times.
1632256 if(Quit)
29874 {
29875 // Just for compat with pre-z3 replays that quit during a scroll.
29876
2/4
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
3 if (replay_is_recording())
29877 {
29878 USE_COMPAT_HERO_POS;
29879 }
29880 3 screenscrolling = false;
29881 3 return;
29882 }
29883
29884
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 SAVE_HERO_POS;
29885
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 USE_COMPAT_HERO_POS;
29886
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 ZScriptVersion::RunScrollingScript(scrolldir, scroll_counter, sx, sy, end_frames, false);
29887
3/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3909291 times.
✓ Branch 3 taken 2277038 times.
1632253 RESTORE_HERO_POS;
29888
29889
2/2
✓ Branch 0 taken 3791717 times.
✓ Branch 1 taken 117574 times.
3909291 if(no_move > 0)
29890 117574 no_move--;
29891
29892 //Don't want to move things on the first or last iteration, or between delays, or while aligning, or while adjusting playing field offset
29893
12/12
✓ Branch 0 taken 1604299 times.
✓ Branch 1 taken 2304992 times.
✓ Branch 2 taken 1563005 times.
✓ Branch 3 taken 41294 times.
✓ Branch 4 taken 1529956 times.
✓ Branch 5 taken 33049 times.
✓ Branch 6 taken 1526616 times.
✓ Branch 7 taken 3340 times.
✓ Branch 8 taken 1166473 times.
✓ Branch 9 taken 2693089 times.
✓ Branch 10 taken 1167337 times.
✓ Branch 11 taken 1529092 times.
3909291 if(i == 0 || scroll_counter == 0 || scroll_counter % delay != 0 || (align_mode == 0 && align_counter) || (pfo_mode == 0 && pfo_counter))
29894 4713145 no_move++;
29895
29896
4/4
✓ Branch 0 taken 1224588 times.
✓ Branch 1 taken 407665 times.
✓ Branch 2 taken 294554 times.
✓ Branch 3 taken 930034 times.
1632253 if(scrolldir == up || scrolldir == down)
29897 {
29898
2/2
✓ Branch 0 taken 652149 times.
✓ Branch 1 taken 50070 times.
702219 if(!get_qr(qr_SMOOTHVERTICALSCROLLING))
29899 {
29900 //Add a few extra frames if on the second loop and cool scrolling is not set
29901
2/2
✓ Branch 0 taken 49389 times.
✓ Branch 1 taken 681 times.
50070 if(i == 1)
29902 {
29903 681 scroll_counter += (scrolldir == down) ? 3 : 2;
29904 681 no_move += (scrolldir == down) ? 3 : 2;
29905 681 }
29906 50070 }
29907 else
29908 {
29909 //4 frames after we've finished scrolling of being still
29910
6/6
✓ Branch 0 taken 26696 times.
✓ Branch 1 taken 625453 times.
✓ Branch 2 taken 26688 times.
✓ Branch 3 taken 8 times.
✓ Branch 4 taken 13344 times.
✓ Branch 5 taken 13344 times.
652149 if (scroll_counter == 0 && pfo_counter == 0 && !end_frames)
29911 {
29912 13344 scroll_counter += 4;
29913 13344 no_move += 4;
29914 13344 end_frames = true;
29915 13344 }
29916 }
29917 702219 }
29918
29919
2/2
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 1628821 times.
1632253 if (align_mode == 0)
29920 {
29921
5/6
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 1628131 times.
✓ Branch 2 taken 252 times.
✓ Branch 3 taken 438 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 252 times.
1628821 if (align_counter > 0 && (pfo_counter == 0 || pfo_mode == 1))
29922 {
29923
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 420 times.
438 align_counter = MAX(0, align_counter - 4);
29924
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 34 times.
438 if (align_counter)
29925 404 scroll_counter++;
29926 438 }
29927 1628821 }
29928 else
29929 {
29930
5/6
✓ Branch 0 taken 3370 times.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 2798 times.
✓ Branch 3 taken 572 times.
✓ Branch 4 taken 2798 times.
✗ Branch 5 not taken.
3432 if (align_counter > 0 && !(scroll_counter >= 0 && delay != 0))
29931 {
29932
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 560 times.
572 align_counter = MAX(0, align_counter - 4);
29933 572 no_move = 1;
29934 572 }
29935 }
29936
29937 1632253 bool do_pfo_adjust = false;
29938
2/2
✓ Branch 0 taken 410073 times.
✓ Branch 1 taken 1222180 times.
1632253 if (pfo_mode == 0)
29939 {
29940
2/2
✓ Branch 0 taken 1221702 times.
✓ Branch 1 taken 478 times.
1222180 if (pfo_counter > 0)
29941 478 do_pfo_adjust = true;
29942 1222180 }
29943 else
29944 {
29945
5/6
✓ Branch 0 taken 2908 times.
✓ Branch 1 taken 407165 times.
✓ Branch 2 taken 2376 times.
✓ Branch 3 taken 532 times.
✓ Branch 4 taken 2376 times.
✗ Branch 5 not taken.
410073 if (pfo_counter > 0 && !(scroll_counter >= 0 && delay != 0))
29946 {
29947 532 do_pfo_adjust = true;
29948 532 no_move = 1;
29949 532 }
29950 }
29951
29952
2/2
✓ Branch 0 taken 1010 times.
✓ Branch 1 taken 1631243 times.
1632253 if (do_pfo_adjust)
29953 {
29954
1/2
✓ Branch 0 taken 1010 times.
✗ Branch 1 not taken.
1010 int dpfo = sign(new_playing_field_offset - old_original_playing_field_offset);
29955
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1008 times.
1010 pfo_counter = MAX(0, pfo_counter - 4);
29956 1010 playing_field_offset = new_playing_field_offset - pfo_counter * dpfo;
29957 1010 viewport.h = 232 - playing_field_offset;
29958 1010 viewport.y = initial_viewport.y + step * move_counter * dy + (playing_field_offset - old_original_playing_field_offset);
29959
4/4
✓ Branch 0 taken 478 times.
✓ Branch 1 taken 532 times.
✓ Branch 2 taken 442 times.
✓ Branch 3 taken 36 times.
1010 if (pfo_mode == 0 && pfo_counter)
29960 442 scroll_counter++;
29961 1010 }
29962
29963
2/2
✓ Branch 0 taken 793 times.
✓ Branch 1 taken 1631460 times.
1632253 if (lift_wpn)
29964
1/2
✓ Branch 0 taken 793 times.
✗ Branch 1 not taken.
793 lift_wpn->yofs = playing_field_offset - 2;
29965
29966
2/2
✓ Branch 0 taken 1486729 times.
✓ Branch 1 taken 145524 times.
1632253 if(!no_move)
29967 {
29968
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 335769 times.
✓ Branch 2 taken 250170 times.
✓ Branch 3 taken 420541 times.
✓ Branch 4 taken 480249 times.
1486729 switch(scrolldir)
29969 {
29970 case up:
29971 335769 sy -= step;
29972 335769 break;
29973
29974 case down:
29975 250170 sy += step;
29976 250170 break;
29977
29978 case left:
29979 420541 sx -= step;
29980 420541 break;
29981
29982 case right:
29983 480249 sx += step;
29984 480249 break;
29985 }
29986
29987 1486729 move_counter++;
29988 {
29989 1486729 viewport.x = initial_viewport.x + step * move_counter * dx;
29990 1486729 viewport.y = initial_viewport.y + step * move_counter * dy + playing_field_offset - old_original_playing_field_offset;
29991 }
29992
29993 // This is the only thing that moves the hero.
29994
2/4
✓ Branch 0 taken 1486729 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1486729 times.
✗ Branch 3 not taken.
1486729 if (!sideview_scrolling_slope)
29995 {
29996
4/4
✓ Branch 0 taken 1066188 times.
✓ Branch 1 taken 420541 times.
✓ Branch 2 taken 585939 times.
✓ Branch 3 taken 480249 times.
1486729 if (scrolling_dir == left || scrolling_dir == right)
29997 {
29998
2/4
✓ Branch 0 taken 900790 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 900790 times.
✗ Branch 3 not taken.
900790 x.doClamp(viewport.x, viewport.right() - 16);
29999 900790 }
30000 else
30001 {
30002
2/4
✓ Branch 0 taken 585939 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 585939 times.
✗ Branch 3 not taken.
585939 y.doClamp(viewport.y, viewport.bottom() - 16);
30003 }
30004 1486729 }
30005
30006
2/2
✓ Branch 0 taken 1472627 times.
✓ Branch 1 taken 14102 times.
1486729 if (is_unsmooth_vertical_scrolling) viewport.y += 3;
30007
30008
4/4
✓ Branch 0 taken 1486601 times.
✓ Branch 1 taken 128 times.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 1486473 times.
1486729 if(ladderx > 0 || laddery > 0)
30009 {
30010 // If the ladder moves on both axes, the player can
30011 // gradually shift it by going back and forth
30012
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(scrolldir==up || scrolldir==down)
30013 laddery = y.getInt();
30014 else
30015
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 ladderx = x.getInt();
30016 256 }
30017 1486729 }
30018
30019
2/2
✓ Branch 0 taken 6314 times.
✓ Branch 1 taken 1625939 times.
1632253 if (secondary_axis_alignment_amount)
30020 {
30021
1/2
✓ Branch 0 taken 6314 times.
✗ Branch 1 not taken.
6314 int delta = (align_counter - abs(secondary_axis_alignment_amount)) * sign(secondary_axis_alignment_amount);
30022
4/4
✓ Branch 0 taken 5944 times.
✓ Branch 1 taken 370 times.
✓ Branch 2 taken 284 times.
✓ Branch 3 taken 5660 times.
6314 if (scrolldir == up || scrolldir == down) viewport.x = initial_viewport.x + delta;
30023 5660 else viewport.y = initial_viewport.y + delta + (playing_field_offset - old_original_playing_field_offset);
30024 6314 }
30025
30026 1632253 FFCore.ScrollingData[SCROLLDATA_NX] = nx - viewport.x;
30027 1632253 FFCore.ScrollingData[SCROLLDATA_NY] = ny - viewport.y;
30028 1632253 FFCore.ScrollingData[SCROLLDATA_OX] = ox - viewport.x;
30029 1632253 FFCore.ScrollingData[SCROLLDATA_OY] = oy - viewport.y;
30030 1632253 FFCore.ScrollingData[SCROLLDATA_NRX] = new_region_offset_x - viewport.x;
30031 1632253 FFCore.ScrollingData[SCROLLDATA_NRY] = new_region_offset_y - viewport.y;
30032 1632253 FFCore.ScrollingData[SCROLLDATA_ORX] = -viewport.x;
30033 1632253 FFCore.ScrollingData[SCROLLDATA_ORY] = -viewport.y;
30034
30035
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 SAVE_HERO_POS;
30036
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 USE_COMPAT_HERO_POS;
30037
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 ZScriptVersion::RunScrollingScript(scrolldir, scroll_counter, sx, sy, end_frames, true); //Waitdraw
30038
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 FFCore.runGenericPassiveEngine(SCR_TIMING_PRE_DRAW);
30039
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 RESTORE_HERO_POS;
30040
30041
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 clear_bitmap(framebuf);
30042
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 clear_info_bmp();
30043
30044
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30045 3290530 mapscr* base_scr = screen_handles[0].base_scr;
30046
2/2
✓ Branch 0 taken 3288922 times.
✓ Branch 1 taken 1608 times.
3290530 if(XOR(base_scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG)) do_layer(framebuf, 0, screen_handles[2], offx, offy);
30047 3290530 });
30048
4/4
✓ Branch 0 taken 847 times.
✓ Branch 1 taken 1631406 times.
✓ Branch 2 taken 1608 times.
✓ Branch 3 taken 1630645 times.
1632253 if(XOR((newscr->flags7&fLAYER2BG) || (oldscr->flags7&fLAYER2BG), DMaps[cur_dmap].flags&dmfLAYER2BG))
30049
1/2
✓ Branch 0 taken 1608 times.
✗ Branch 1 not taken.
1608 do_primitives(framebuf, 2);
30050
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, -2, nearby_screens, new_region_offset_x, new_region_offset_y);
30051
30052
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30053 3290530 mapscr* base_scr = screen_handles[0].base_scr;
30054
2/2
✓ Branch 0 taken 3280306 times.
✓ Branch 1 taken 10224 times.
3290530 if(XOR(base_scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG)) do_layer(framebuf, 0, screen_handles[3], offx, offy);
30055 3290530 });
30056
4/4
✓ Branch 0 taken 5079 times.
✓ Branch 1 taken 1627174 times.
✓ Branch 2 taken 6769 times.
✓ Branch 3 taken 1625484 times.
1632253 if(XOR((newscr->flags7&fLAYER3BG) || (oldscr->flags7&fLAYER3BG), DMaps[cur_dmap].flags&dmfLAYER3BG))
30057
1/2
✓ Branch 0 taken 6769 times.
✗ Branch 1 not taken.
6769 do_primitives(framebuf, 3);
30058
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, -3, nearby_screens, new_region_offset_x, new_region_offset_y);
30059
30060 1632253 combotile_add_y = is_unsmooth_vertical_scrolling ? -3 : 0;
30061
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30062 3290530 offy += playing_field_offset;
30063
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3290530 times.
3290530 if (lenscheck(screen_handles[0].scr, 0))
30064 3290530 putscr(screen_handles[0].scr, framebuf, offx, offy);
30065 3290530 });
30066 1632253 combotile_add_y = 0;
30067
30068
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 if (lenscheck(newscr, 0))
30069
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_primitives(framebuf, 0);
30070
30071
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 0, nearby_screens, new_region_offset_x, new_region_offset_y);
30072
30073
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30074 3290530 do_layer(framebuf, 0, screen_handles[1], offx, offy);
30075 3290530 });
30076
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_layer_primitives(framebuf, 1);
30077
30078
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 1, nearby_screens, new_region_offset_x, new_region_offset_y);
30079
30080
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30081 3290530 mapscr* base_scr = screen_handles[0].base_scr;
30082
2/2
✓ Branch 0 taken 1608 times.
✓ Branch 1 taken 3288922 times.
3290530 if (!(XOR(base_scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG)))
30083 3288922 do_layer(framebuf, 0, screen_handles[2], offx, offy);
30084 3290530 });
30085
30086
4/4
✓ Branch 0 taken 1631492 times.
✓ Branch 1 taken 761 times.
✓ Branch 2 taken 1630645 times.
✓ Branch 3 taken 847 times.
1632253 if (!(oldscr->flags7&fLAYER2BG) && !(XOR(origin_scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG)))
30087
1/2
✓ Branch 0 taken 1630645 times.
✗ Branch 1 not taken.
1630645 do_layer_primitives(framebuf, 2);
30088
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 2, nearby_screens, new_region_offset_x, new_region_offset_y);
30089
30090
2/2
✓ Branch 0 taken 17236 times.
✓ Branch 1 taken 1615017 times.
1632253 if (get_qr(qr_PUSHBLOCK_SPRITE_LAYER))
30091 {
30092
1/2
✓ Branch 0 taken 1615017 times.
✗ Branch 1 not taken.
4871075 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30093 3256058 do_layer(framebuf, -2, screen_handles[0], offx, offy);
30094
2/2
✓ Branch 0 taken 3127350 times.
✓ Branch 1 taken 128708 times.
3256058 if (get_qr(qr_PUSHBLOCK_LAYER_1_2))
30095 {
30096 128708 do_layer(framebuf, -2, screen_handles[1], offx, offy);
30097 128708 do_layer(framebuf, -2, screen_handles[2], offx, offy);
30098 128708 }
30099 3256058 });
30100
30101
1/2
✓ Branch 0 taken 1615017 times.
✗ Branch 1 not taken.
1615017 do_primitives(framebuf, SPLAYER_PUSHBLOCK);
30102 1615017 }
30103
30104
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1632253 times.
1632253 if (show_walkflags || show_effectflags)
30105 {
30106 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30107 do_walkflags(screen_handles, offx, offy); // show walkflags if the cheat is on
30108 do_effectflags(screen_handles[0].base_scr, offx, offy); // show effectflags if the cheat is on
30109 });
30110
30111 do_walkflags(nx, ny);
30112 }
30113
30114
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30115 3290530 offy += playing_field_offset;
30116 3290530 putscrdoors(screen_handles[0].scr, framebuf, offx, offy);
30117 3290530 });
30118
30119
4/4
✓ Branch 0 taken 3982 times.
✓ Branch 1 taken 1628271 times.
✓ Branch 2 taken 3938 times.
✓ Branch 3 taken 44 times.
1632253 if (!align_counter || scroll_counter) herostep();
30120
30121 {
30122
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 auto prev_y = y;
30123
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 auto prev_yofs = yofs;
30124
30125
3/4
✓ Branch 0 taken 50070 times.
✓ Branch 1 taken 1582183 times.
✓ Branch 2 taken 50070 times.
✗ Branch 3 not taken.
1632253 if (is_unsmooth_vertical_scrolling) y += 3;
30126
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 yofs = playing_field_offset;
30127
30128
7/12
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1631489 times.
✓ Branch 5 taken 764 times.
✓ Branch 6 taken 1631489 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1631489 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1632253 times.
1632253 if((z > 0 || fakez > 0) && (!get_qr(qr_SHADOWSFLICKER) || frame&1))
30129 {
30130
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 1631489 times.
1632253 drawshadow(framebuf, get_qr(qr_TRANSSHADOWS) != 0);
30131 764 }
30132
30133
6/6
✓ Branch 0 taken 1632253 times.
✓ Branch 1 taken 1631489 times.
✓ Branch 2 taken 615767 times.
✓ Branch 3 taken 1016486 times.
✓ Branch 4 taken 295458 times.
✓ Branch 5 taken 320309 times.
764 if(!isdungeon() || get_qr(qr_FREEFORM))
30134 {
30135
3/4
✓ Branch 0 taken 1350340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38396 times.
✓ Branch 3 taken 1311944 times.
1350340 for (int i = 0; i < decorations.Count(); i++)
30136 {
30137
1/2
✓ Branch 0 taken 38396 times.
✗ Branch 1 not taken.
38396 auto sprite = decorations.spr(i);
30138
1/2
✓ Branch 0 taken 38396 times.
✗ Branch 1 not taken.
38396 sprite->yofs += playing_field_offset - old_original_playing_field_offset;
30139 38396 }
30140
30141
1/2
✓ Branch 0 taken 1311944 times.
✗ Branch 1 not taken.
1311944 draw_under(framebuf); //draw the ladder or raft
30142
1/2
✓ Branch 0 taken 1311944 times.
✗ Branch 1 not taken.
1311944 decorations.draw2(framebuf, true);
30143
1/2
✓ Branch 0 taken 1311944 times.
✗ Branch 1 not taken.
1311944 draw(framebuf); //Hero
30144
1/2
✓ Branch 0 taken 1311944 times.
✗ Branch 1 not taken.
1311944 decorations.draw(framebuf, true);
30145
30146
3/4
✓ Branch 0 taken 1350340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38396 times.
✓ Branch 3 taken 1311944 times.
1350340 for (int i = 0; i < decorations.Count(); i++)
30147 {
30148
1/2
✓ Branch 0 taken 38396 times.
✗ Branch 1 not taken.
38396 auto sprite = decorations.spr(i);
30149
1/2
✓ Branch 0 taken 38396 times.
✗ Branch 1 not taken.
38396 sprite->yofs -= playing_field_offset - old_original_playing_field_offset;
30150 38396 }
30151 1311944 }
30152
30153
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 y = prev_y;
30154
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 yofs = prev_yofs;
30155 }
30156
30157
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 RESTORE_HERO_POS;
30158
30159
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30160 3290530 mapscr* base_scr = screen_handles[0].base_scr;
30161
2/2
✓ Branch 0 taken 10224 times.
✓ Branch 1 taken 3280306 times.
3290530 if (!(XOR(base_scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG)))
30162 3280306 do_layer(framebuf, 0, screen_handles[3], offx, offy);
30163 3290530 });
30164
30165
2/2
✓ Branch 0 taken 1627174 times.
✓ Branch 1 taken 5079 times.
1632253 if (!(XOR(origin_scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG)))
30166
1/2
✓ Branch 0 taken 1627174 times.
✗ Branch 1 not taken.
1627174 do_layer_primitives(framebuf, 3);
30167
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 3, nearby_screens, new_region_offset_x, new_region_offset_y);
30168
30169
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30170 3290530 do_layer(framebuf, 0, screen_handles[4], offx, offy); //layer 4
30171 3290530 });
30172
30173
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_layer_primitives(framebuf, 4);
30174
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 4, nearby_screens, new_region_offset_x, new_region_offset_y);
30175
30176
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30177 3290530 do_layer(framebuf, -1, screen_handles[0], offx, offy); //overhead combos
30178
2/2
✓ Branch 0 taken 3151618 times.
✓ Branch 1 taken 138912 times.
3290530 if (get_qr(qr_OVERHEAD_COMBOS_L1_L2))
30179 {
30180 138912 do_layer(framebuf, -1, screen_handles[1], offx, offy); //overhead combos
30181 138912 do_layer(framebuf, -1, screen_handles[2], offx, offy); //overhead combos
30182 138912 }
30183 3290530 });
30184
30185
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30186 3290530 do_layer(framebuf, 0, screen_handles[5], offx, offy); //layer 5
30187 3290530 });
30188
30189
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_layer_primitives(framebuf, 5);
30190
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 5, nearby_screens, new_region_offset_x, new_region_offset_y);
30191
30192
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, -1, nearby_screens, new_region_offset_x, new_region_offset_y);
30193
30194
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
4922783 for_every_nearby_screen_during_scroll(nearby_screens, [&](screen_handles_t screen_handles, int screen, int offx, int offy, bool is_new_screen) {
30195 3290530 do_layer(framebuf, 0, screen_handles[6], offx, offy); //layer 6
30196 3290530 });
30197
30198
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_layer_primitives(framebuf, 6);
30199
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 6, nearby_screens, new_region_offset_x, new_region_offset_y);
30200
30201
6/6
✓ Branch 0 taken 88610 times.
✓ Branch 1 taken 1543643 times.
✓ Branch 2 taken 10406 times.
✓ Branch 3 taken 78204 times.
✓ Branch 4 taken 9814 times.
✓ Branch 5 taken 592 times.
1632253 if (draw_dark && get_qr(qr_NEW_DARKROOM) && get_qr(qr_NEWDARK_L6))
30202 {
30203
1/2
✓ Branch 0 taken 9814 times.
✗ Branch 1 not taken.
9814 scrollscr_handle_dark(newscr, oldscr, nearby_screens);
30204 9814 }
30205
30206
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 put_passive_subscr(framebuf, 0, 0, game->should_show_time(), sspUP);
30207
30208
2/2
✓ Branch 0 taken 599269 times.
✓ Branch 1 taken 1032984 times.
1632253 if(get_qr(qr_SUBSCREENOVERSPRITES))
30209
1/2
✓ Branch 0 taken 599269 times.
✗ Branch 1 not taken.
599269 do_primitives(framebuf, 7);
30210
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 do_ffc_scroll_layer(framebuf, 7, nearby_screens, new_region_offset_x, new_region_offset_y);
30211
30212
6/6
✓ Branch 0 taken 88610 times.
✓ Branch 1 taken 1543643 times.
✓ Branch 2 taken 10406 times.
✓ Branch 3 taken 78204 times.
✓ Branch 4 taken 592 times.
✓ Branch 5 taken 9814 times.
1632253 if (draw_dark && get_qr(qr_NEW_DARKROOM) && !get_qr(qr_NEWDARK_L6))
30213 {
30214
1/2
✓ Branch 0 taken 592 times.
✗ Branch 1 not taken.
592 scrollscr_handle_dark(newscr, oldscr, nearby_screens);
30215 592 }
30216
30217
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 SAVE_HERO_POS;
30218
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 USE_COMPAT_HERO_POS;
30219
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 FFCore.runGenericPassiveEngine(SCR_TIMING_POST_DRAW);
30220
1/2
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
1632253 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
30221
30222
2/4
✓ Branch 0 taken 1632253 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632253 times.
✗ Branch 3 not taken.
1632253 RESTORE_HERO_POS;
30223
2/2
✓ Branch 0 taken 1632252 times.
✓ Branch 1 taken 1 times.
1632253 advanceframe(true/*,true,false*/);
30224
2/4
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632252 times.
✗ Branch 3 not taken.
1632252 USE_COMPAT_HERO_POS;
30225
30226 //Don't clear the last frame, unless 'fixed'
30227
2/2
✓ Branch 0 taken 28724 times.
✓ Branch 1 taken 1603528 times.
1632252 if (scroll_counter > 0 || get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
30228
2/2
✓ Branch 0 taken 1606186 times.
✓ Branch 1 taken 26066 times.
1632252 script_drawing_commands.Clear();
30229
2/2
✓ Branch 0 taken 1632252 times.
✓ Branch 1 taken 26066 times.
1606186 FFCore.runGenericPassiveEngine(SCR_TIMING_START_FRAME);
30230 1632252 actiontype lastaction = action;
30231
1/2
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
1632252 action=scrolling; FFCore.setHeroAction(scrolling);
30232
1/2
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
1632252 FFCore.runF6Engine();
30233
1/2
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
1632252 action=lastaction; FFCore.setHeroAction(lastaction);
30234
30235
2/4
✓ Branch 0 taken 1632252 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1632252 times.
✗ Branch 3 not taken.
1632252 RESTORE_HERO_POS;
30236 1632252 }
30237 27950 cur_dmap = old_dmap;
30238
30239 // TODO(replays): Prior to z3 refactor, old scrolling code didn't clear the darkroom bitmaps at end of scroll,
30240 // so the first frame drawn had some lighting from previous screen...
30241 // game_loop clears these bitmaps but that should be moved to advanceframe, and these other calls to `clear_darkroom_bitmaps`
30242 // deleted.
30243
4/6
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 26520 times.
✓ Branch 2 taken 1430 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1430 times.
27950 if (draw_dark && !replay_is_active())
30244 clear_darkroom_bitmaps();
30245
30246
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 clear_bitmap(msg_txt_display_buf);
30247
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 set_clip_state(msg_txt_display_buf, 1);
30248
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 clear_bitmap(msg_bg_display_buf);
30249
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 set_clip_state(msg_bg_display_buf, 1);
30250
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 clear_bitmap(msg_portrait_display_buf);
30251
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 set_clip_state(msg_portrait_display_buf, 1);
30252
30253 27950 viewport = new_viewport;
30254 27950 playing_field_offset = new_playing_field_offset;
30255
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 x = new_hero_x;
30256
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 y = new_hero_y;
30257
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 yofs = playing_field_offset;
30258
2/2
✓ Branch 0 taken 27948 times.
✓ Branch 1 taken 2 times.
27950 if(ladderx > 0 || laddery > 0)
30259 {
30260 // If the ladder moves on both axes, the player can
30261 // gradually shift it by going back and forth
30262
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 27946 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
27950 if(scrolldir==up || scrolldir==down)
30263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27946 times.
27946 laddery = y.getInt();
30264 else
30265
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 ladderx = x.getInt();
30266 4 }
30267
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 35 times.
4 if (lift_wpn)
30268
1/2
✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
35 lift_wpn->yofs = playing_field_offset - 2;
30269
30270
10/14
✓ Branch 0 taken 27950 times.
✓ Branch 1 taken 27880 times.
✓ Branch 2 taken 27950 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27936 times.
✓ Branch 5 taken 14 times.
✓ Branch 6 taken 27936 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27936 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14 times.
✓ Branch 11 taken 27936 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 14 times.
70 if((z > 0 || fakez > 0) && isSideViewHero())
30271 {
30272 y -= z;
30273 y -= fakez;
30274 z = 0;
30275 fakez = 0;
30276 }
30277
30278
2/2
✓ Branch 0 taken 27950 times.
✓ Branch 1 taken 27936 times.
14 set_respawn_point(false);
30279
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 trySideviewLadder();
30280 27950 warpx = -1;
30281 27950 warpy = -1;
30282
30283 27950 screenscrolling = false;
30284 27950 scrolling_using_new_region_coords = false;
30285 27950 scrolling_destdmap = -1;
30286 27950 memset(FFCore.ScrollingData, 0, sizeof(int32_t) * SZ_SCROLLDATA);
30287 27950 FFCore.ScrollingData[SCROLLDATA_DIR] = -1;
30288
30289
2/2
✓ Branch 0 taken 26922 times.
✓ Branch 1 taken 1028 times.
27950 if (destdmap != -1)
30290 {
30291 1028 bool changedlevel = false;
30292 1028 bool changeddmap = false;
30293
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 171 times.
1028 if (cur_dmap != destdmap)
30294 {
30295
1/2
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
857 timeExitAllGenscript(GENSCR_ST_CHANGE_DMAP);
30296 857 changeddmap = true;
30297 857 }
30298
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 846 times.
1028 if (DMaps[cur_dmap].level != DMaps[destdmap].level)
30299 {
30300
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 timeExitAllGenscript(GENSCR_ST_CHANGE_LEVEL);
30301 182 changedlevel = true;
30302 182 }
30303 1028 dlevel = DMaps[destdmap].level;
30304 1028 cur_dmap = destdmap;
30305
2/2
✓ Branch 0 taken 857 times.
✓ Branch 1 taken 171 times.
1028 if (changeddmap)
30306 {
30307
1/2
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
857 throwGenScriptEvent(GENSCR_EVENT_CHANGE_DMAP);
30308 857 }
30309
2/2
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 846 times.
1028 if (changedlevel)
30310 {
30311
1/2
✓ Branch 0 taken 182 times.
✗ Branch 1 not taken.
182 throwGenScriptEvent(GENSCR_EVENT_CHANGE_LEVEL);
30312 182 }
30313 1028 }
30314
30315 //if Hero is going from non-water to water, and we set his animation to "hopping" above, we must now
30316 //change it to swimming - since we have manually moved Hero onto the first tile, the hopping code
30317 //will get confused and try to hop Hero onto the next (possibly nonexistant) water tile in his current
30318 //direction. -DD
30319
30320
2/2
✓ Branch 0 taken 348 times.
✓ Branch 1 taken 27602 times.
27950 if(nowinwater)
30321 {
30322
1/2
✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
348 SetSwim();
30323 348 hopclk = 0xFF;
30324 348 }
30325
30326 // NES behaviour: Fade to light after scrolling
30327
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 lighting(false, false); // No, we don't need to set naturaldark...
30328
30329
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 init_dmap();
30330
30331 // Check for raft flags
30332
4/4
✓ Branch 0 taken 1173 times.
✓ Branch 1 taken 26777 times.
✓ Branch 2 taken 25940 times.
✓ Branch 3 taken 57 times.
53947 if((get_qr(qr_BROKEN_RAFT_SCROLL) || lastaction == rafting)
30333
4/4
✓ Branch 0 taken 26323 times.
✓ Branch 1 taken 1627 times.
✓ Branch 2 taken 25997 times.
✓ Branch 3 taken 326 times.
27950 && action!=rafting && hopclk==0 && !toogam)
30334 {
30335
9/16
✓ Branch 0 taken 25940 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25940 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 25940 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 25935 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 25935 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 25935 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 25935 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 25935 times.
✗ Branch 15 not taken.
25940 if(MAPFLAG(x,y)==mfRAFT||MAPCOMBOFLAG(x,y)==mfRAFT)
30336 {
30337
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 sfx(hero_scr->secretsfx);
30338
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 action=rafting; FFCore.setHeroAction(rafting);
30339 5 raftclk=0;
30340 5 }
30341
30342 // Half a tile off?
30343
16/28
✓ Branch 0 taken 19656 times.
✓ Branch 1 taken 6279 times.
✓ Branch 2 taken 7071 times.
✓ Branch 3 taken 12585 times.
✓ Branch 4 taken 13350 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 13350 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 13350 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 13350 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 13350 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13350 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 13350 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 13350 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 13350 times.
✗ Branch 21 not taken.
✓ Branch 22 taken 13350 times.
✗ Branch 23 not taken.
✓ Branch 24 taken 13350 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 25935 times.
39285 else if((dir==left || dir==right) && (MAPFLAG(x,y+8)==mfRAFT||MAPCOMBOFLAG(x,y+8)==mfRAFT))
30344 {
30345 sfx(hero_scr->secretsfx);
30346 action=rafting; FFCore.setHeroAction(rafting);
30347 raftclk=0;
30348 }
30349 25940 }
30350
30351
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
56676 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
30352 28726 get_screen_state(scr->screen).open_doors = 0;
30353 28726 });
30354
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 markBmap();
30355
30356
3/4
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8704 times.
✓ Branch 3 taken 19246 times.
27950 if (isdungeon(current_screen))
30357 {
30358
4/4
✓ Branch 0 taken 5100 times.
✓ Branch 1 taken 1694 times.
✓ Branch 2 taken 1904 times.
✓ Branch 3 taken 6 times.
8704 switch(hero_scr->door[scrolldir^1])
30359 {
30360 case dNONE:
30361 6 dir = scrolldir;
30362 6 break;
30363 case dOPEN:
30364 case dUNLOCKED:
30365 case dOPENBOSS:
30366 5100 dir = scrolldir;
30367
30368
1/2
✓ Branch 0 taken 5100 times.
✗ Branch 1 not taken.
5100 if(action!=rafting)
30369
1/2
✓ Branch 0 taken 5100 times.
✗ Branch 1 not taken.
5100 stepforward(diagonalMovement?11:12, false);
30370
30371 5100 break;
30372
30373 case dSHUTTER:
30374 case d1WAYSHUTTER:
30375 1694 dir = scrolldir;
30376
30377
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if(action!=rafting)
30378
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 stepforward(diagonalMovement?21:24, false);
30379
30380
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 putdoor(hero_scr, scrollbuf, scrolldir^1, hero_scr->door[scrolldir^1]);
30381
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 get_screen_state(hero_scr->screen).open_doors = -4;
30382
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 sfx(WAV_DOOR);
30383 1694 break;
30384
30385 default:
30386 1904 dir = scrolldir;
30387
30388
2/2
✓ Branch 0 taken 1857 times.
✓ Branch 1 taken 47 times.
1904 if(action!=rafting)
30389
1/2
✓ Branch 0 taken 1857 times.
✗ Branch 1 not taken.
1857 stepforward(diagonalMovement?21:24, false);
30390 1904 }
30391 8704 }
30392
30393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27950 times.
27950 if(action == scrolling)
30394 {
30395 action=none; FFCore.setHeroAction(none);
30396 }
30397
30398
3/4
✓ Branch 0 taken 27918 times.
✓ Branch 1 taken 32 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27918 times.
27950 if(action != attacking && action != sideswimattacking)
30399 {
30400 27918 charging = 0;
30401 27918 tapping = false;
30402 27918 }
30403
30404
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 map_bkgsfx(true);
30405
30406
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 27916 times.
27950 if(newscr->flags2&fSECRET_SFX)
30407 {
30408
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 sfx(newscr->secretsfx);
30409 34 }
30410
30411
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 if (updatemusic)
30412 {
30413
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 playLevelMusic();
30414
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 if (musicrevert)
30415 FFCore.music_update_cond = MUSIC_UPDATE_SCREEN;
30416 27950 }
30417
30418 // It happens that all decorations that are not drawn with an offset
30419 // are temporary sprites (like combo sprites) that should never carry over.
30420
3/4
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27950 times.
✓ Branch 3 taken 702 times.
28652 for (int i = decorations.Count()-1; i >=0; i--)
30421 {
30422
1/2
✓ Branch 0 taken 702 times.
✗ Branch 1 not taken.
702 auto sprite = (decoration*)decorations.spr(i);
30423
3/4
✓ Branch 0 taken 702 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 695 times.
702 if (!sprite->is_drawn_with_offset())
30424
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 decorations.remove(sprite); // TODO: improve deletions by adding remove_by_index
30425
4/4
✓ Branch 0 taken 681 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 677 times.
695 else if (old_region.region_id || new_region.region_id)
30426
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 sprite->yofs = playing_field_offset;
30427 702 }
30428
30429 27950 newscr_clk = frame;
30430 27950 activated_timed_warp=false;
30431 27950 loadside = scrolldir^1;
30432
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 FFCore.clear_combo_scripts();
30433
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 eventlog_mapflags();
30434
1/2
✓ Branch 0 taken 27950 times.
✗ Branch 1 not taken.
27950 decorations.animate(); //continue to animate tall grass during scrolling
30435
2/2
✓ Branch 0 taken 1884 times.
✓ Branch 1 taken 26066 times.
27950 if(get_qr(qr_FIXSCRIPTSDURINGSCROLLING))
30436 {
30437
5/6
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 1838 times.
✓ Branch 2 taken 46 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 40 times.
1884 if (old_dmap == new_dmap || (replay_version_check(0, 15)))
30438 {
30439
1/2
✓ Branch 0 taken 1844 times.
✗ Branch 1 not taken.
1844 ZScriptVersion::RunScrollingScript(scrolldir, scroll_counter, sx, sy, end_frames, false); //Prewaitdraw
30440 1844 }
30441 1884 }
30442
30443 // Bye!
30444
2/2
✓ Branch 0 taken 5731419 times.
✓ Branch 1 taken 5759369 times.
27950 delete_temporary_screens(old_temporary_screens.data());
30445 5731419 FFCore.ScrollingScreensAll.clear();
30446
30447
2/2
✓ Branch 0 taken 5729963 times.
✓ Branch 1 taken 1456 times.
5731419 if(!get_qr(qr_SCROLLWARP_NO_RESET_FRAME))
30448 1456 GameFlags |= GAMEFLAG_RESET_GAME_LOOP;
30449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5731422 times.
17250160 }
30450
30451 // How much to reduce Hero's damage, taking into account various rings.
30452 15269 int32_t HeroClass::ringpower(int32_t dmg, bool noPeril, bool noRing)
30453 {
30454
1/2
✓ Branch 0 taken 15269 times.
✗ Branch 1 not taken.
15269 if(dmg < 0) return dmg; //Don't reduce healing
30455
2/2
✓ Branch 0 taken 14539 times.
✓ Branch 1 taken 730 times.
15269 if ( get_qr(qr_BROKEN_RING_POWER) )
30456 {
30457 14539 int32_t divisor = 1;
30458 14539 float percentage = 1;
30459 14539 int32_t itemid = current_item_id(itype_ring);
30460 14539 bool usering = false;
30461
30462
4/4
✓ Branch 0 taken 10813 times.
✓ Branch 1 taken 3726 times.
✓ Branch 2 taken 324 times.
✓ Branch 3 taken 10489 times.
14539 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
30463 {
30464 10489 usering = true;
30465 10489 paymagiccost(itemid);
30466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10489 times.
10489 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
30467 {
30468 percentage *= itemsbuf[itemid].power/100.0;
30469 }
30470 else
30471 {
30472 10489 divisor *= itemsbuf[itemid].power;
30473 }
30474 10489 }
30475
30476 /* Now for the Peril Ring */
30477 14539 itemid = current_item_id(itype_perilring);
30478
30479
8/10
✓ Branch 0 taken 2844 times.
✓ Branch 1 taken 11695 times.
✓ Branch 2 taken 2698 times.
✓ Branch 3 taken 146 times.
✓ Branch 4 taken 402 times.
✓ Branch 5 taken 2296 times.
✓ Branch 6 taken 402 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 402 times.
14539 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
30480 {
30481 402 usering = true;
30482 402 paymagiccost(itemid);
30483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 402 times.
402 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
30484 {
30485 percentage *= itemsbuf[itemid].power/100.0;
30486 }
30487 else
30488 {
30489 402 divisor *= itemsbuf[itemid].power;
30490 }
30491 402 }
30492
30493 // Ring divisor of 0 = no damage. -L
30494
4/6
✓ Branch 0 taken 10507 times.
✓ Branch 1 taken 4032 times.
✓ Branch 2 taken 10507 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10507 times.
14539 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
30495 return 0;
30496
30497
1/2
✓ Branch 0 taken 14539 times.
✗ Branch 1 not taken.
14539 if( percentage < 0 ) percentage = (percentage * -1) + 1; //Negative percentage = that percent MORE damage -V
30498
30499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14539 times.
14539 if ( divisor < 0 ) return dmg * percentage * (divisor*-1);
30500
1/2
✓ Branch 0 taken 14539 times.
✗ Branch 1 not taken.
14539 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
30501
30502 }
30503 else
30504 {
30505 730 double divisor = 1;
30506 730 double percentage = 1;
30507 730 int32_t itemid = current_item_id(itype_ring);
30508 730 bool usering = false;
30509
30510
3/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 727 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
730 if(itemid>-1 && !noRing) // current_item_id checks magic cost for rings
30511 {
30512 3 usering = true;
30513 3 paymagiccost(itemid);
30514
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
30515 {
30516 1 double perc = itemsbuf[itemid].power/100.0;
30517
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
30518 1 percentage *= perc;
30519 1 }
30520 else
30521 {
30522
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(itemsbuf[itemid].power < 0)
30523 divisor /= -(itemsbuf[itemid].power);
30524 2 else divisor *= itemsbuf[itemid].power;
30525 }
30526 3 }
30527
30528 /* Now for the Peril Ring */
30529 730 itemid = current_item_id(itype_perilring);
30530
30531
4/10
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
730 if(itemid>-1 && !noPeril && game->get_life()<=itemsbuf[itemid].misc1*game->get_hp_per_heart() && checkmagiccost(itemid) && checkbunny(itemid))
30532 {
30533 usering = true;
30534 paymagiccost(itemid);
30535 if(itemsbuf[itemid].flags & item_flag2)//"Divisor is Percentage Multiplier" flag
30536 {
30537 double perc = itemsbuf[itemid].power/100.0;
30538 if(perc < 0) perc = -perc + 1; //Negative percentage = that percent MORE damage -V
30539 percentage *= perc;
30540 }
30541 else
30542 {
30543 if(itemsbuf[itemid].power < 0)
30544 divisor /= -(itemsbuf[itemid].power);
30545 else divisor *= itemsbuf[itemid].power;
30546 }
30547 }
30548
30549 // Ring divisor of 0 = no damage. -L
30550
4/6
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 727 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
730 if(usering && (divisor==0 || percentage==0)) //Change dto allow negative power rings. -Z
30551 return 0;
30552
30553 //if ( divisor < 0 ) return dmg * percentage * (divisor*-1); //handle this further up now
30554
1/2
✓ Branch 0 taken 730 times.
✗ Branch 1 not taken.
730 return dmg*percentage/( divisor != 0 ? divisor : 1 ); //zc_max(divisor, 1); // well, better safe...
30555 }
30556 15269 }
30557
30558 // Should swinging the hammer make the 'pound' sound?
30559 // Or is Hero just hitting air?
30560 6476 bool HeroClass::sideviewhammerpound()
30561 {
30562 6476 int32_t wx=0,wy=0;
30563
30564
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1022 times.
✓ Branch 2 taken 1520 times.
✓ Branch 3 taken 2137 times.
✓ Branch 4 taken 1797 times.
6476 switch(dir)
30565 {
30566 case up:
30567 1022 wx=-1;
30568 1022 wy=-15;
30569
30570
1/2
✓ Branch 0 taken 1022 times.
✗ Branch 1 not taken.
1022 if(isSideViewHero()) wy+=8;
30571
30572 1022 break;
30573
30574 case down:
30575 1520 wx=8;
30576 1520 wy=28;
30577
30578
1/2
✓ Branch 0 taken 1520 times.
✗ Branch 1 not taken.
1520 if(isSideViewHero()) wy-=8;
30579
30580 1520 break;
30581
30582 case left:
30583 2137 wx=-8;
30584 2137 wy=14;
30585
30586
2/2
✓ Branch 0 taken 2125 times.
✓ Branch 1 taken 12 times.
2137 if(isSideViewHero()) wy+=8;
30587
30588 2137 break;
30589
30590 case right:
30591 1797 wx=21;
30592 1797 wy=14;
30593
30594
1/2
✓ Branch 0 taken 1797 times.
✗ Branch 1 not taken.
1797 if(isSideViewHero()) wy+=8;
30595
30596 1797 break;
30597 }
30598
30599
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 6464 times.
6476 if(!isSideViewHero())
30600 {
30601
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 6455 times.
6464 return (COMBOTYPE(x+wx,y+wy)!=cSHALLOWWATER && !iswaterex_z3(MAPCOMBO(x+wx,y+wy), -1, x+wx,y+wy));
30602 }
30603
30604
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
12 if(_walkflag(x+wx,y+wy,0,STANDING_Z_STATE)) return true;
30605
30606 if(dir==left || dir==right)
30607 {
30608 wx+=16;
30609
30610 if(_walkflag(x+wx,y+wy,0,STANDING_Z_STATE)) return true;
30611 }
30612
30613 return false;
30614 6476 }
30615
30616 // The following are only used for Hero damage. Damage is in quarter hearts.
30617 9215 int32_t enemy_dp(int32_t index)
30618 {
30619 9215 return (((enemy*)guys.spr(index))->dp)*(game->get_ene_dmgmult());
30620 }
30621
30622 5448 int32_t ewpn_dp(int32_t index)
30623 {
30624 5448 return (((weapon*)Ewpns.spr(index))->power)*(game->get_ene_dmgmult());
30625 }
30626
30627 43 int32_t lwpn_dp(int32_t index)
30628 {
30629 43 return (((weapon*)Lwpns.spr(index))->power)*(game->get_ene_dmgmult());
30630 }
30631
30632 137880116 bool checkbunny(int32_t itemid)
30633 {
30634
3/4
✓ Branch 0 taken 137779516 times.
✓ Branch 1 taken 100600 times.
✓ Branch 2 taken 100600 times.
✗ Branch 3 not taken.
137880116 return !Hero.BunnyClock() || (itemid > 0 && itemsbuf[itemid].flags&item_bunny_enabled);
30635 }
30636
30637 16916168 bool usesSwordJinx(int32_t itemid)
30638 {
30639 16916168 itemdata const& it = itemsbuf[itemid];
30640 16916168 bool ret = (it.type==itype_sword);
30641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16916168 times.
16916168 if(it.flags & item_flip_jinx) return !ret;
30642 16916168 return ret;
30643 16916168 }
30644 40627222 bool checkitem_jinx(int32_t itemid)
30645 {
30646 40627222 itemdata const& it = itemsbuf[itemid];
30647
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 40623072 times.
40627222 if(it.flags & item_jinx_immune) return true;
30648
2/2
✓ Branch 0 taken 31306883 times.
✓ Branch 1 taken 9316189 times.
40623072 if (it.type == itype_shield){
30649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31306883 times.
31306883 if(HeroShieldClk() != 0) return false;
30650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31306883 times.
31306883 if(it.flags & !item_flag9) //Active Shields should also check sword/item jinx flags
30651 {
30652 if (usesSwordJinx(itemid)) return HeroSwordClk() == 0;
30653 return HeroItemClk() == 0;
30654 }
30655 31306883 return true;
30656
30657 }
30658
2/2
✓ Branch 0 taken 8460439 times.
✓ Branch 1 taken 855750 times.
9316189 if(usesSwordJinx(itemid)) return HeroSwordClk() == 0;
30659 855750 return HeroItemClk() == 0;
30660 40627222 }
30661
30662 2 void stopCaneOfByrna()
30663 {
30664
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 2 times.
42 for (int32_t i = 0; i < Lwpns.Count(); i++)
30665 {
30666 40 weapon* w = ((weapon*)Lwpns.spr(i));
30667
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 38 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
40 if (w->id == wCByrna && !w->weapon_dying_frame)
30668 2 w->dead = 1;
30669 40 }
30670 2 }
30671
30672 //Check if there are no beams, kill sfx, and reset last_cane_of_byrna_item_id
30673 14306886 void HeroClass::cleanupByrna()
30674 {
30675
2/2
✓ Branch 0 taken 14306809 times.
✓ Branch 1 taken 77 times.
14306886 if ( last_cane_of_byrna_item_id > -1 )
30676 {
30677
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 75 times.
77 if ( !(Lwpns.idCount(wCByrna)) )
30678 {
30679 2 stop_sfx(itemsbuf[last_cane_of_byrna_item_id].usesound);
30680 2 last_cane_of_byrna_item_id = -1;
30681 2 }
30682 77 }
30683 14306886 }
30684
30685 // Used to find out if an item family is attached to one of the buttons currently pressed.
30686 4508163 bool isWpnPressed(int32_t itype)
30687 {
30688
4/4
✓ Branch 0 taken 529630 times.
✓ Branch 1 taken 3978533 times.
✓ Branch 2 taken 464621 times.
✓ Branch 3 taken 65009 times.
4508163 if ((itype == getItemFamily(itemsbuf, Bwpn)) && getInput(btnB, INPUT_DRUNK | INPUT_HERO_ACTION)) return true;
30689
4/4
✓ Branch 0 taken 1593785 times.
✓ Branch 1 taken 2849369 times.
✓ Branch 2 taken 655017 times.
✓ Branch 3 taken 938768 times.
4443154 if ((itype == getItemFamily(itemsbuf, Awpn)) && getInput(btnA, INPUT_DRUNK | INPUT_HERO_ACTION)) return true;
30690
4/4
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 3502956 times.
✓ Branch 2 taken 566 times.
✓ Branch 3 taken 864 times.
3504386 if ((itype == getItemFamily(itemsbuf, Xwpn)) && getInput(btnEx1, INPUT_DRUNK | INPUT_HERO_ACTION)) return true;
30691
4/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 3503460 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 27 times.
3503522 if ((itype == getItemFamily(itemsbuf, Ywpn)) && getInput(btnEx2, INPUT_DRUNK | INPUT_HERO_ACTION)) return true;
30692 3503487 return false;
30693 4508163 }
30694
30695 13733766 int32_t getWpnPressed(int32_t itype)
30696 {
30697
4/4
✓ Branch 0 taken 403543 times.
✓ Branch 1 taken 13330223 times.
✓ Branch 2 taken 394816 times.
✓ Branch 3 taken 8727 times.
13733766 if ((itype == getItemFamily(itemsbuf, Bwpn)) && getInput(btnB, INPUT_DRUNK | INPUT_HERO_ACTION)) return Bwpn & 0xFFF;
30698
3/4
✓ Branch 0 taken 28064 times.
✓ Branch 1 taken 13696975 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28064 times.
13725039 if ((itype == getItemFamily(itemsbuf, Awpn)) && getInput(btnA, INPUT_DRUNK | INPUT_HERO_ACTION)) return Awpn & 0xFFF;
30699
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13696975 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13696975 if ((itype == getItemFamily(itemsbuf, Xwpn)) && getInput(btnEx1, INPUT_DRUNK | INPUT_HERO_ACTION)) return Xwpn & 0xFFF;
30700
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13696975 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
13696975 if ((itype == getItemFamily(itemsbuf, Ywpn)) && getInput(btnEx2, INPUT_DRUNK | INPUT_HERO_ACTION)) return Ywpn & 0xFFF;
30701
30702 13696975 return -1;
30703 13733766 }
30704
30705 14309408 int32_t getRocsPressed()
30706 {
30707 14309408 int32_t jumpid = current_item_id(itype_rocs,true,true);
30708
30709
2/2
✓ Branch 0 taken 399372 times.
✓ Branch 1 taken 13910036 times.
14309408 if(unsigned(jumpid) >= MAXITEMS) jumpid = -1;
30710
30711
2/2
✓ Branch 0 taken 13910036 times.
✓ Branch 1 taken 399372 times.
14309408 if (jumpid != -1)
30712 {
30713 399372 itemdata const& itm = itemsbuf[jumpid];
30714
30715 399372 byte intbtn = byte(itm.misc2&0xFF);
30716
1/2
✓ Branch 0 taken 399372 times.
✗ Branch 1 not taken.
399372 if (getIntBtnInput(intbtn, INPUT_DRUNK | INPUT_PEEK))
30717 return jumpid; //not pressed
30718 399372 }
30719
30720
4/4
✓ Branch 0 taken 121155 times.
✓ Branch 1 taken 14188253 times.
✓ Branch 2 taken 115578 times.
✓ Branch 3 taken 5577 times.
14309408 if ((itype_rocs == getItemFamily(itemsbuf, Bwpn)) && getInput(btnB, INPUT_DRUNK | INPUT_HERO_ACTION))
30721 5577 return Bwpn;
30722
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14303831 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14303831 if ((itype_rocs == getItemFamily(itemsbuf, Awpn)) && getInput(btnA, INPUT_DRUNK | INPUT_HERO_ACTION))
30723 return Awpn;
30724
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14303831 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14303831 if ((itype_rocs == getItemFamily(itemsbuf, Xwpn)) && getInput(btnEx1, INPUT_DRUNK | INPUT_HERO_ACTION))
30725 return Xwpn;
30726
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14303831 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14303831 if ((itype_rocs == getItemFamily(itemsbuf, Ywpn)) && getInput(btnEx2, INPUT_DRUNK | INPUT_HERO_ACTION))
30727 return Ywpn;
30728
30729 14303831 return -1;
30730 14309408 }
30731
30732 bool isItmPressed(int32_t itmid)
30733 {
30734 if (itmid == (NEG_OR_MASK(Bwpn, 0xFFF)) && getInput(btnB, INPUT_DRUNK | INPUT_HERO_ACTION)) return true;
30735 if (itmid == (NEG_OR_MASK(Awpn, 0xFFF)) && getInput(btnA, INPUT_DRUNK | INPUT_HERO_ACTION)) return true;
30736 if (itmid == (NEG_OR_MASK(Xwpn, 0xFFF)) && getInput(btnEx1, INPUT_DRUNK | INPUT_HERO_ACTION)) return true;
30737 if (itmid == (NEG_OR_MASK(Ywpn, 0xFFF)) && getInput(btnEx2, INPUT_DRUNK | INPUT_HERO_ACTION)) return true;
30738 return false;
30739 }
30740
30741 //helper function
30742 23884 static void selectNextBTNWpn(int32_t type, word& wpos, int32_t& BTNwpn,
30743 int32_t& directItemBTN, word f1 = 255, word f2 = 255, word f3 = 255)
30744 {
30745
1/2
✓ Branch 0 taken 23884 times.
✗ Branch 1 not taken.
23884 if(!new_subscreen_active)
30746 return;
30747 23884 byte pgn = wpos&0xFF, pos = wpos>>8;
30748 23884 bool empty = pgn==255;
30749
3/4
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13986 times.
✓ Branch 2 taken 9898 times.
✗ Branch 3 not taken.
23884 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
30750
2/2
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13986 times.
23884 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
30751
1/2
✓ Branch 0 taken 23884 times.
✗ Branch 1 not taken.
23884 if(!pg)
30752 return;
30753
4/6
✓ Branch 0 taken 22497 times.
✓ Branch 1 taken 1387 times.
✓ Branch 2 taken 1387 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1387 times.
23884 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
30754
4/6
✓ Branch 0 taken 23880 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
23884 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
30755
4/6
✓ Branch 0 taken 23880 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4 times.
23884 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
30756 23884 auto ret = pg->movepos_legacy(type, wpos, fp1, fp2, fp3);
30757
2/2
✓ Branch 0 taken 9898 times.
✓ Branch 1 taken 13986 times.
23884 if((ret&0xFF) == 0xFF)
30758 9898 BTNwpn = -1;
30759 13986 else BTNwpn = pg->get_item_pos(ret>>8);
30760
2/2
✓ Branch 0 taken 13986 times.
✓ Branch 1 taken 9898 times.
23884 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
30761 23884 wpos = ret;
30762 23884 }
30763 5661 void selectNextAWpn(int32_t type)
30764 {
30765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5661 times.
5661 if(!get_qr(qr_SELECTAWPN))
30766 return;
30767
2/4
✓ Branch 0 taken 5661 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5661 times.
5661 selectNextBTNWpn(type, game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
30768 5661 }
30769
30770 18223 void selectNextBWpn(int32_t type)
30771 {
30772
1/2
✓ Branch 0 taken 18223 times.
✗ Branch 1 not taken.
18223 if(!new_subscreen_active)
30773 return;
30774
6/6
✓ Branch 0 taken 12897 times.
✓ Branch 1 taken 5326 times.
✓ Branch 2 taken 18219 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 18219 times.
18223 selectNextBTNWpn(type, game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
30775 18223 }
30776
30777 void selectNextXWpn(int32_t type)
30778 {
30779 if(!get_qr(qr_SET_XBUTTON_ITEMS)) return;
30780 if(!new_subscreen_active)
30781 return;
30782 selectNextBTNWpn(type, game->xwpn, Xwpn, directItemX, COND_BWPN, COND_AWPN, COND_YWPN);
30783 }
30784
30785 void selectNextYWpn(int32_t type)
30786 {
30787 if(!get_qr(qr_SET_YBUTTON_ITEMS)) return;
30788 if(!new_subscreen_active)
30789 return;
30790 selectNextBTNWpn(type, game->ywpn, Ywpn, directItemY, COND_BWPN, COND_XWPN, COND_AWPN);
30791 }
30792
30793 //helper function
30794 32086942 static void verifyWpn(word& wpos, int32_t& BTNwpn, int32_t& directItemBTN, word f1 = 255, word f2 = 255, word f3 = 255)
30795 {
30796
2/2
✓ Branch 0 taken 32079009 times.
✓ Branch 1 taken 7933 times.
32086942 if(!new_subscreen_active)
30797 7933 return;
30798 32079009 byte pgn = wpos&0xFF, pos = wpos>>8;
30799 32079009 bool empty = pgn==255;
30800
4/4
✓ Branch 0 taken 2576467 times.
✓ Branch 1 taken 29502542 times.
✓ Branch 2 taken 1030549 times.
✓ Branch 3 taken 1545918 times.
32079009 if(empty && get_qr(qr_NO_BUTTON_VERIFY)) return; //intentional nothingness
30801
2/2
✓ Branch 0 taken 1030549 times.
✓ Branch 1 taken 29502542 times.
30533091 SubscrPage* pg = new_subscreen_active->get_page(pgn==255?new_subscreen_active->curpage:pgn);
30802
1/2
✓ Branch 0 taken 30533091 times.
✗ Branch 1 not taken.
30533091 if(!pg)
30803 return;
30804
5/6
✓ Branch 0 taken 22812935 times.
✓ Branch 1 taken 7720156 times.
✓ Branch 2 taken 7661234 times.
✓ Branch 3 taken 58922 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7661234 times.
30533091 auto fp1 = ((f1&0xFF)==255) ? 255 : ((empty || (f1&0xFF)==(wpos&0xFF)) ? f1 : 255);
30805
5/6
✓ Branch 0 taken 24536144 times.
✓ Branch 1 taken 5996947 times.
✓ Branch 2 taken 5996359 times.
✓ Branch 3 taken 588 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5996359 times.
30533091 auto fp2 = ((f2&0xFF)==255) ? 255 : ((empty || (f2&0xFF)==(wpos&0xFF)) ? f2 : 255);
30806
5/6
✓ Branch 0 taken 25340491 times.
✓ Branch 1 taken 5192600 times.
✓ Branch 2 taken 5192581 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5192581 times.
30533091 auto fp3 = ((f3&0xFF)==255) ? 255 : ((empty || (f3&0xFF)==(wpos&0xFF)) ? f3 : 255);
30807 30533091 wpos = pg->movepos_legacy(SEL_VERIFY_RIGHT, wpos, fp1, fp2, fp3);
30808
2/2
✓ Branch 0 taken 1030383 times.
✓ Branch 1 taken 29502708 times.
30533091 if((wpos&0xFF) == 0xFF)
30809 1030383 BTNwpn = -1;
30810 29502708 else BTNwpn = pg->get_item_pos(wpos>>8);
30811
2/2
✓ Branch 0 taken 29239935 times.
✓ Branch 1 taken 1293156 times.
30533091 directItemBTN = NEG_OR_MASK(BTNwpn,0xFFF);
30812 32086942 }
30813
30814 24273635 void verifyAWpn()
30815 {
30816
2/2
✓ Branch 0 taken 1019 times.
✓ Branch 1 taken 24272616 times.
24273635 if (game->forced_awpn != -1)
30817 1019 return;
30818
2/2
✓ Branch 0 taken 1482248 times.
✓ Branch 1 taken 22790368 times.
24272616 if(!get_qr(qr_SELECTAWPN))
30819 {
30820 22790368 Awpn = selectSword();
30821 22790368 game->awpn = 255;
30822 22790368 }
30823 else
30824 {
30825
4/4
✓ Branch 0 taken 932155 times.
✓ Branch 1 taken 550093 times.
✓ Branch 2 taken 550093 times.
✓ Branch 3 taken 932155 times.
1482248 verifyWpn(game->awpn, Awpn, directItemA, COND_BWPN, COND_XWPN, COND_YWPN);
30826 }
30827 24273635 }
30828
30829 24267263 void verifyBWpn()
30830 {
30831
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 24266250 times.
24267263 if (game->forced_bwpn != -1)
30832 1013 return;
30833
6/6
✓ Branch 0 taken 1481412 times.
✓ Branch 1 taken 22784838 times.
✓ Branch 2 taken 3169222 times.
✓ Branch 3 taken 21097028 times.
✓ Branch 4 taken 3169222 times.
✓ Branch 5 taken 21097028 times.
24266250 verifyWpn(game->bwpn, Bwpn, directItemB, COND_AWPN, COND_XWPN, COND_YWPN);
30834 24267263 }
30835
30836 24267263 void verifyXWpn()
30837 {
30838
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 24266250 times.
24267263 if (game->forced_xwpn != -1)
30839 1013 return;
30840
2/2
✓ Branch 0 taken 3169222 times.
✓ Branch 1 taken 21097028 times.
24266250 if(!get_qr(qr_SET_XBUTTON_ITEMS))
30841 21097028 return;
30842
3/4
✓ Branch 0 taken 2619821 times.
✓ Branch 1 taken 549401 times.
✓ Branch 2 taken 3169222 times.
✗ Branch 3 not taken.
3169222 verifyWpn(game->xwpn, Xwpn, directItemX, COND_BWPN, COND_AWPN, COND_YWPN);
30843 24267263 }
30844
30845 24267263 void verifyYWpn()
30846 {
30847
2/2
✓ Branch 0 taken 1013 times.
✓ Branch 1 taken 24266250 times.
24267263 if (game->forced_ywpn != -1)
30848 1013 return;
30849
2/2
✓ Branch 0 taken 3169222 times.
✓ Branch 1 taken 21097028 times.
24266250 if(!get_qr(qr_SET_YBUTTON_ITEMS))
30850 21097028 return;
30851
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3169222 times.
✓ Branch 2 taken 549401 times.
✓ Branch 3 taken 2619821 times.
3169222 verifyWpn(game->ywpn, Ywpn, directItemY, COND_BWPN, COND_XWPN, COND_AWPN);
30852 24267263 }
30853
30854 24267263 void verifyBothWeapons()
30855 {
30856 24267263 verifyAWpn();
30857 24267263 verifyBWpn();
30858 24267263 verifyXWpn();
30859 24267263 verifyYWpn();
30860 24267263 }
30861
30862 // Select the sword for the A button if the 'select A button weapon' quest rule isn't set.
30863 22790776 int32_t selectSword()
30864 {
30865 22790776 return current_item_id(itype_sword);
30866 }
30867
30868 // Adding code here for allowing hardcoding a button to a specific itemclass.
30869 int32_t selectItemclass(int32_t itemclass)
30870 {
30871 int32_t ret = current_item_id(itemclass);
30872
30873 if(ret == -1)
30874 ret = 0;
30875
30876 return ret;
30877 }
30878
30879 // Used for the 'Pickup Hearts' item pickup condition.
30880 304 bool canget(int32_t id)
30881 {
30882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 304 times.
304 return id>=0 && (game->get_maxlife()>=(itemsbuf[id].pickup_hearts*game->get_hp_per_heart()));
30883 }
30884
30885 63 void dospecialmoney(mapscr* scr, int32_t index)
30886 {
30887
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 19 times.
63 if (cur_screen >= 128)
30888 19 scr = special_warp_return_scr;
30889
30890 63 int32_t priceindex = ((item*)items.spr(index))->PriceIndex;
30891
30892
4/7
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
63 switch (scr->room)
30893 {
30894 case rINFO: // pay for info
30895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(prices[priceindex]!=100000 ) // 100000 is a placeholder price for free items
30896 {
30897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!current_item_power(itype_wallet))
30898 {
30899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if (game->get_spendable_rupies() < abs(prices[priceindex]))
30900 return;
30901 16 int32_t tmpprice = -abs(prices[priceindex]);
30902 16 int32_t total = game->get_drupy()-tmpprice;
30903 16 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30904 16 game->set_drupy(game->get_drupy()-total);
30905 //game->change_drupy(-abs(prices[priceindex]));
30906 16 }
30907
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if ( current_item_power(itype_wallet)>0 )
30908 {
30909 game->change_drupy(0);
30910 }
30911 16 }
30912 16 rectfill(msg_bg_display_buf, 0, 0, msg_bg_display_buf->w, 80, 0);
30913 16 rectfill(msg_txt_display_buf, 0, 0, msg_txt_display_buf->w, 80, 0);
30914 16 donewmsg(scr, QMisc.info[scr->catchall].str[priceindex]);
30915 16 clear_bitmap(pricesdisplaybuf);
30916 16 set_clip_state(pricesdisplaybuf, 1);
30917 16 items.del(0);
30918
30919
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for(int32_t i=0; i<items.Count(); i++)
30920 48 ((item*)items.spr(i))->pickup=ipDUMMY;
30921
30922 // Prevent the prices from being displayed anymore
30923
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
64 for(int32_t i=0; i<3; i++)
30924 {
30925 48 prices[i] = 0;
30926 48 }
30927
30928 16 break;
30929
30930 case rMONEY: // secret money
30931 {
30932 20 ((item*)items.spr(0))->pickup = ipDUMMY;
30933
30934 20 prices[0] = scr->catchall;
30935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (!current_item_power(itype_wallet))
30936 20 game->change_drupy(prices[0]);
30937 //game->set_drupy(game->get_drupy()+price); may be needed everywhere
30938
30939 20 putprices(false);
30940
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
20 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
30941 20 break;
30942 }
30943
30944 case rGAMBLE: // gamble
30945 {
30946 if(game->get_spendable_rupies()<10 && !current_item_power(itype_wallet)) return; //Why 10?
30947
30948 unsigned si=(zc_oldrand()%24)*3;
30949
30950 for(int32_t i=0; i<3; i++)
30951 prices[i]=gambledat[si++];
30952
30953 game->set_drupy(game->get_drupy()+prices[priceindex]);
30954 putprices(true);
30955
30956 for(int32_t i=1; i<4; i++)
30957 ((item*)items.spr(i))->pickup=ipDUMMY;
30958 }
30959 break;
30960
30961 case rBOMBS:
30962 {
30963
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15 if(game->get_spendable_rupies()<scr->catchall && !current_item_power(itype_wallet))
30964 return;
30965
30966 15 int32_t price = -scr->catchall;
30967 15 int32_t wmedal = current_item_id(itype_wealthmedal);
30968
1/2
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
15 if(wmedal >= 0)
30969 {
30970 if(itemsbuf[wmedal].flags & item_flag1)
30971 price*=(itemsbuf[wmedal].misc1/100.0);
30972 else
30973 price+=itemsbuf[wmedal].misc1;
30974 }
30975
30976 15 int32_t total = game->get_drupy()-price;
30977 15 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
30978 15 game->set_drupy(game->get_drupy()-total);
30979 //game->set_drupy(game->get_drupy()+price);
30980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
30981 15 game->change_maxbombs(4);
30982 15 game->set_bombs(game->get_maxbombs());
30983 {
30984 15 int32_t div = zinit.bomb_ratio;
30985
30986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
15 if(div > 0)
30987 15 game->change_maxcounter(4/div, 6);
30988 }
30989
30990 //also give Hero an actual Bomb item
30991
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 15 times.
3855 for(int32_t i=0; i<MAXITEMS; i++)
30992 {
30993
4/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 3823 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 15 times.
3840 if(itemsbuf[i].type == itype_bomb && itemsbuf[i].level == 1)
30994 15 getitem(i, true, true);
30995 3840 }
30996
30997 15 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
30998 15 fadeclk=66;
30999 15 dismissmsg();
31000 15 clear_bitmap(pricesdisplaybuf);
31001 15 set_clip_state(pricesdisplaybuf, 1);
31002 15 verifyBothWeapons();
31003 15 break;
31004 }
31005
31006 case rARROWS:
31007 {
31008 if(game->get_spendable_rupies()<scr->catchall && !current_item_power(itype_wallet))
31009 return;
31010
31011 int32_t price = -scr->catchall;
31012 int32_t wmedal = current_item_id(itype_wealthmedal);
31013 if(wmedal >= 0)
31014 {
31015 if(itemsbuf[wmedal].flags & item_flag1)
31016 price*=(itemsbuf[wmedal].misc1/100.0);
31017 else
31018 price+=itemsbuf[wmedal].misc1;
31019 }
31020
31021 int32_t total = game->get_drupy()-price;
31022 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
31023 game->set_drupy(game->get_drupy()-total);
31024
31025 //game->set_drupy(game->get_drupy()+price);
31026 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
31027 game->change_maxarrows(10);
31028 game->set_arrows(game->get_maxarrows());
31029 ((item*)items.spr(index))->pickup=ipDUMMY+ipFADE;
31030 fadeclk=66;
31031 dismissmsg();
31032 clear_bitmap(pricesdisplaybuf);
31033 set_clip_state(pricesdisplaybuf, 1);
31034 verifyBothWeapons();
31035 break;
31036 }
31037
31038 case rSWINDLE:
31039
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(items.spr(index)->id==iRupy)
31040 {
31041
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if(game->get_spendable_rupies()<scr->catchall && !current_item_power(itype_wallet))
31042 return;
31043 12 int32_t tmpprice = -scr->catchall;
31044 12 int32_t total = game->get_drupy()-tmpprice;
31045 12 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
31046 12 game->set_drupy(game->get_drupy()-total);
31047 12 }
31048 else
31049 {
31050 if(game->get_maxlife()<=game->get_hp_per_heart())
31051 return;
31052
31053 game->set_life(zc_max(game->get_life()-game->get_hp_per_heart(),0));
31054 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),(game->get_hp_per_heart())));
31055 }
31056
31057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 setmapflag(scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
31058 12 ((item*)items.spr(0))->pickup=ipDUMMY+ipFADE;
31059 12 ((item*)items.spr(1))->pickup=ipDUMMY+ipFADE;
31060 12 fadeclk=66;
31061 12 dismissmsg();
31062 12 clear_bitmap(pricesdisplaybuf);
31063 12 set_clip_state(pricesdisplaybuf, 1);
31064 12 break;
31065 }
31066 63 }
31067
31068 24044 void getitem(int32_t id, bool nosound, bool doRunPassive)
31069 {
31070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24044 times.
24044 if(unsigned(id) >= MAXITEMS)
31071 return;
31072
31073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24044 times.
24044 if (replay_is_active())
31074
1/2
✓ Branch 0 taken 24044 times.
✗ Branch 1 not taken.
24044 replay_step_comment(fmt::format("getitem {}", item_string[id]));
31075
31076
2/2
✓ Branch 0 taken 23563 times.
✓ Branch 1 taken 481 times.
24044 if(get_qr(qr_SCC_ITEM_COMBINES_ITEMS))
31077 {
31078 481 int32_t nextitem = -1;
31079 481 do
31080 {
31081 481 nextitem = -1;
31082
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 481 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
481 if((itemsbuf[id].flags & item_combine) && game->get_item(id))
31083 // Item upgrade routine.
31084 {
31085
31086 for(int32_t i=0; i<MAXITEMS; i++)
31087 {
31088 // Find the item which is as close to this item's fam_type as possible.
31089 if(itemsbuf[i].type==itemsbuf[id].type && itemsbuf[i].level>itemsbuf[id].level
31090 && (nextitem>-1 ? itemsbuf[i].level<=itemsbuf[nextitem].level : true))
31091 {
31092 nextitem = i;
31093 }
31094 }
31095
31096 if(nextitem>-1)
31097 {
31098 id = nextitem;
31099 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
31100 break; //no looping
31101 }
31102 }
31103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 481 times.
481 } while(nextitem > -1);
31104 481 }
31105
31106 24044 itemdata const& idat = itemsbuf[id&0xFF];
31107
31108 48088 bool equipment = idat.flags &
31109 24044 ((idat.type == itype_triforcepiece) ? item_flag8 : item_gamedata);
31110
31111
2/2
✓ Branch 0 taken 19915 times.
✓ Branch 1 taken 4129 times.
24044 if(equipment)
31112 {
31113 // Fix boomerang sounds.
31114 4129 int32_t itemid = current_item_id(idat.type);
31115
31116
4/6
✓ Branch 0 taken 1727 times.
✓ Branch 1 taken 2402 times.
✓ Branch 2 taken 1644 times.
✓ Branch 3 taken 83 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4129 if(itemid>=0 && (idat.type == itype_brang || idat.type == itype_divineprotection
31117
5/6
✓ Branch 0 taken 1644 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1610 times.
✓ Branch 3 taken 34 times.
✓ Branch 4 taken 1609 times.
✓ Branch 5 taken 1 times.
1644 || idat.type == itype_hookshot || idat.type == itype_switchhook || idat.type == itype_cbyrna)
31118 1727 && sfx_allocated(itemsbuf[itemid].usesound)
31119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1727 times.
1727 && idat.usesound != itemsbuf[itemid].usesound)
31120 {
31121 stop_sfx(itemsbuf[itemid].usesound);
31122 cont_sfx(idat.usesound);
31123 }
31124
31125 4129 int32_t curitm = current_item_id(idat.type);
31126
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
4129 if(!get_qr(qr_KEEPOLD_APPLIES_RETROACTIVELY)
31127
4/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4125 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 3 times.
4129 || curitm < 0 || (itemsbuf[curitm].level <= idat.level)
31128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 || (itemsbuf[curitm].flags & item_keep_old))
31129 {
31130 4129 game->set_item(id,true);
31131 4129 passiveitem_script(id, doRunPassive);
31132 4129 }
31133
31134
2/2
✓ Branch 0 taken 819 times.
✓ Branch 1 taken 3310 times.
4129 if(!(idat.flags & item_keep_old))
31135 {
31136
4/4
✓ Branch 0 taken 1143 times.
✓ Branch 1 taken 2167 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 1104 times.
3310 if(!get_qr(qr_BROKEN_KEEPOLD_FLAG) || current_item(idat.type)<idat.level)
31137 {
31138 2206 removeLowerLevelItemsOfFamily(game,itemsbuf,idat.type, idat.level);
31139 2206 }
31140 3310 }
31141
31142 // NES consistency: replace all flying boomerangs with the current boomerang.
31143
2/2
✓ Branch 0 taken 3977 times.
✓ Branch 1 taken 152 times.
4129 if(idat.type==itype_brang)
31144
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 152 times.
153 for(int32_t i=0; i<Lwpns.Count(); i++)
31145 {
31146 1 weapon *w = ((weapon*)Lwpns.spr(i));
31147
31148
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(w->id==wBrang)
31149 {
31150 w->LOADGFX(idat.wpn);
31151 }
31152 153 }
31153 4129 }
31154
31155
2/2
✓ Branch 0 taken 4705 times.
✓ Branch 1 taken 19339 times.
24044 if(idat.count!=-1)
31156 {
31157
2/2
✓ Branch 0 taken 18624 times.
✓ Branch 1 taken 715 times.
19339 if(idat.setmax)
31158 {
31159 // Bomb bags are a special case; they may be set not to increase super bombs
31160
5/6
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 597 times.
✓ Branch 2 taken 118 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 114 times.
✓ Branch 5 taken 4 times.
715 if(idat.type==itype_bombbag && idat.count==2 && (idat.flags&16)==0)
31161 {
31162 4 int32_t max = game->get_maxbombs();
31163
31164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(max<idat.max) max=idat.max;
31165
31166
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 game->set_maxbombs(zc_min(game->get_maxbombs()+idat.setmax,max), false);
31167 4 }
31168 else
31169 {
31170 711 int32_t max = game->get_maxcounter(idat.count);
31171
31172
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 435 times.
711 if(max<idat.max) max=idat.max;
31173
31174
2/2
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 414 times.
711 game->set_maxcounter(zc_min(game->get_maxcounter(idat.count)+idat.setmax,max), idat.count);
31175 }
31176 715 }
31177
31178 // Amount is an uint16_t, but the range is -9999 to 16383
31179 // -1 is actually 16385 ... -9999 is 26383, and 0x8000 means use the drain counter
31180
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 18807 times.
19339 if(idat.amount&0x3FFF)
31181 {
31182
2/2
✓ Branch 0 taken 10789 times.
✓ Branch 1 taken 8018 times.
18807 if(idat.amount&0x8000)
31183 21578 game->set_dcounter(
31184
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10788 times.
10789 game->get_dcounter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
31185 else
31186 {
31187
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8018 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8018 if(idat.amount>=16385 && game->get_counter(0)<=idat.amount-16384)
31188 game->set_counter(0, idat.count);
31189 else
31190 // This is too confusing to try and change...
31191
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 8018 times.
✓ Branch 2 taken 3758 times.
✓ Branch 3 taken 4260 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 3758 times.
8018 game->set_counter(zc_min(game->get_counter(idat.count)+((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF),game->get_maxcounter(idat.count)), idat.count);
31192 }
31193 18807 }
31194 19339 }
31195
31196
2/2
✓ Branch 0 taken 24043 times.
✓ Branch 1 taken 1 times.
24044 if(idat.pickup_litems)
31197 {
31198 1 auto lvl = idat.pickup_litem_level;
31199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(lvl < 0)
31200 1 lvl = dlevel;
31201 1 game->lvlitems[lvl] |= idat.pickup_litems;
31202 1 }
31203
31204
4/4
✓ Branch 0 taken 24006 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 2633 times.
✓ Branch 3 taken 21373 times.
24044 if(idat.playsound&&!nosound)
31205 {
31206 21373 sfx(idat.playsound);
31207 21373 }
31208
31209 //add lower-level items
31210
2/2
✓ Branch 0 taken 23958 times.
✓ Branch 1 taken 86 times.
24044 if(idat.flags&item_gain_old)
31211 {
31212
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 86 times.
192 for(int32_t i=idat.level-1; i>0; i--)
31213 {
31214 106 int32_t potid = getItemID(itemsbuf, idat.type, i);
31215
31216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
106 if(potid != -1)
31217 {
31218 106 game->set_item(potid, true);
31219 106 }
31220 106 }
31221 86 }
31222
31223
12/14
✓ Branch 0 taken 175 times.
✓ Branch 1 taken 22127 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 475 times.
✓ Branch 6 taken 128 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 102 times.
✓ Branch 9 taken 89 times.
✓ Branch 10 taken 72 times.
✓ Branch 11 taken 724 times.
✓ Branch 12 taken 119 times.
✓ Branch 13 taken 24 times.
24044 switch(idat.type)
31224 {
31225 case itype_itmbundle:
31226 {
31227
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!itembundle_safe(id & 0xFF))
31228 break;
31229 24 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
31230 20 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
31231 4 bool pscript = (idat.flags & item_flag1);
31232
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 4 times.
44 for(auto q = 0; q < 10; ++q)
31233 {
31234
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 33 times.
40 if(unsigned(ids[q]) >= MAXITEMS) continue;
31235
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 10 times.
33 if(pscript)
31236 10 collectitem_script(ids[q]);
31237
31238 33 getitem(ids[q], true, true);
31239 33 }
31240 }
31241 4 break;
31242
31243 case itype_progressive_itm:
31244 {
31245 int32_t newid = get_progressive_item(id);
31246 if(newid > -1)
31247 getitem(newid, nosound, true);
31248 }
31249 break;
31250
31251 case itype_bottlefill:
31252 {
31253 if(idat.misc1)
31254 {
31255 game->fillBottle(idat.misc1);
31256 }
31257 }
31258 break;
31259
31260 case itype_clock:
31261 {
31262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
475 if(idat.flags & item_flag1) //Active use, not passive
31263 break;
31264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 475 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
475 if((idat.flags & item_flag2) && clockclk) //"Can't activate while clock active"
31265 break;
31266 475 setClock(watch=true);
31267
31268 475 clock_zoras.clear();
31269
31270 475 clockclk=idat.misc1;
31271 475 sfx(idat.usesound);
31272 }
31273 475 break;
31274
31275 case itype_lkey:
31276 {
31277 128 auto lvl = dlevel;
31278
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(idat.flags & item_flag1) // custom level
31279 lvl = vbound(idat.misc1, 0, MAXLEVELS-1);
31280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(game->lvlkeys[lvl]<255)
31281 128 game->lvlkeys[lvl]++;
31282 128 break;
31283 }
31284
31285 case itype_ring:
31286 case itype_magicring:
31287
6/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 153 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 2 times.
175 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (cur_screen<128 || dlevel))
31288 {
31289 173 ringcolor(false);
31290 173 }
31291 175 break;
31292
31293 case itype_whispring:
31294 {
31295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(idat.flags & item_flag1)
31296 {
31297
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroSwordClk()==-1) setSwordClk(150); // Let's not bother applying the divisor.
31298
31299
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroItemClk()==-1) setItemClk(150); // Let's not bother applying the divisor.
31300
31301
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(HeroItemClk()== 1) setShieldClk(150); // Let's not bother applying the divisor.
31302 5 }
31303
31304
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2 times.
5 if(idat.power==0)
31305 {
31306 2 setSwordClk(0);
31307 2 setItemClk(0);
31308 2 setShieldClk(0);
31309 2 }
31310
31311 5 break;
31312 }
31313
31314
31315 case itype_map:
31316 102 game->lvlitems[dlevel]|=liMAP;
31317 102 break;
31318
31319 case itype_compass:
31320 89 game->lvlitems[dlevel]|=liCOMPASS;
31321 89 break;
31322
31323 case itype_bosskey:
31324 72 game->lvlitems[dlevel]|=liBOSSKEY;
31325 72 break;
31326
31327 case itype_fairy:
31328
31329
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 205 times.
✓ Branch 3 taken 519 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 205 times.
724 game->set_life(zc_min(game->get_life()+(idat.flags&item_flag1 ?(int32_t)(game->get_maxlife()*(idat.misc1/100.0)):((idat.misc1*game->get_hp_per_heart()))),game->get_maxlife()));
31330
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 724 times.
✓ Branch 2 taken 115 times.
✓ Branch 3 taken 609 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 115 times.
724 game->set_magic(zc_min(game->get_magic()+(idat.flags&item_flag2 ?(int32_t)(game->get_maxmagic()*(idat.misc2/100.0)):((idat.misc2*game->get_mp_per_block()))),game->get_maxmagic()));
31331 724 break;
31332
31333 case itype_heartpiece:
31334 119 game->change_HCpieces(1);
31335
31336
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 26 times.
119 if(game->get_HCpieces()<game->get_hcp_per_hc())
31337 93 break;
31338
31339 26 game->set_HCpieces(0);
31340
31341 26 getitem(heart_container_id());
31342 26 break;
31343
31344 case itype_killem:
31345 {
31346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(idat.flags & item_flag1) //Active use, not passive
31347 break;
31348 24 kill_em_all();
31349 24 sfx(idat.usesound);
31350 }
31351 24 break;
31352 }
31353
31354 24044 flushItemCache();
31355 24044 update_subscreens();
31356 24044 refresh_subscr_items();
31357 24044 verifyBothWeapons();
31358 24044 }
31359
31360 11 void takeitem(int32_t id)
31361 {
31362 11 game->set_item(id, false);
31363 11 itemdata const& idat = itemsbuf[id];
31364
31365 /* Lower the counters! */
31366
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(idat.count!=-1)
31367 {
31368 if(idat.setmax)
31369 {
31370 game->set_maxcounter(game->get_maxcounter(idat.count)-idat.setmax, idat.count);
31371 }
31372
31373 if(idat.amount&0x3FFF)
31374 {
31375 if(idat.amount&0x8000)
31376 game->set_dcounter(game->get_dcounter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
31377 else game->set_counter(game->get_counter(idat.count)-((idat.amount&0x4000)?-(idat.amount&0x3FFF):idat.amount&0x3FFF), idat.count);
31378 }
31379 }
31380
31381
1/10
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11 switch(itemsbuf[id&0xFF].type)
31382 {
31383 // NES consistency: replace all flying boomerangs with the current boomerang.
31384 case itype_brang:
31385 if(current_item(itype_brang)) for(int32_t i=0; i<Lwpns.Count(); i++)
31386 {
31387 weapon *w = ((weapon*)Lwpns.spr(i));
31388
31389 if(w->id==wBrang)
31390 {
31391 w->LOADGFX(itemsbuf[current_item_id(itype_brang)].wpn);
31392 }
31393 }
31394
31395 break;
31396
31397 case itype_itmbundle:
31398 {
31399 if(!itembundle_safe(id))
31400 break;
31401 int ids[10] = {idat.misc1, idat.misc2, idat.misc3, idat.misc4, idat.misc5,
31402 idat.misc6, idat.misc7, idat.misc8, idat.misc9, idat.misc10};
31403 for(auto q = 0; q < 10; ++q)
31404 {
31405 if(unsigned(ids[q]) >= MAXITEMS) continue;
31406 takeitem(ids[q]);
31407 }
31408 }
31409 break;
31410
31411 case itype_progressive_itm:
31412 {
31413 int32_t newid = get_progressive_item(id, true);
31414 if(newid > -1)
31415 takeitem(newid);
31416 }
31417 break;
31418
31419 case itype_heartpiece:
31420 if(game->get_maxlife()>game->get_hp_per_heart())
31421 {
31422 if(game->get_HCpieces()==0)
31423 {
31424 game->set_HCpieces(game->get_hcp_per_hc());
31425 takeitem(iHeartC);
31426 }
31427
31428 game->change_HCpieces(-1);
31429 }
31430 break;
31431
31432 case itype_map:
31433 game->lvlitems[dlevel]&=~liMAP;
31434 break;
31435
31436 case itype_compass:
31437 game->lvlitems[dlevel]&=~liCOMPASS;
31438 break;
31439
31440 case itype_bosskey:
31441 game->lvlitems[dlevel]&=~liBOSSKEY;
31442 break;
31443
31444 case itype_lkey:
31445 {
31446 auto lvl = dlevel;
31447 if(idat.flags & item_flag1) // custom level
31448 lvl = vbound(idat.misc1, 0, MAXLEVELS-1);
31449 if(game->lvlkeys[lvl])
31450 game->lvlkeys[lvl]--;
31451 break;
31452 }
31453
31454 case itype_ring:
31455 if((get_qr(qr_OVERWORLDTUNIC) != 0) || (cur_screen<128 || dlevel))
31456 {
31457 ringcolor(false);
31458 }
31459 break;
31460 }
31461 11 }
31462
31463 14238 void post_item_collect()
31464 {
31465 14238 std::vector<int32_t> &ev = FFCore.eventData;
31466 14238 ev.clear();
31467
31468 14238 throwGenScriptEvent(GENSCR_EVENT_POST_COLLECT_ITEM);
31469 14238 }
31470
31471 14459 void HeroClass::handle_triforce(mapscr* scr, int32_t id)
31472 {
31473
1/2
✓ Branch 0 taken 14459 times.
✗ Branch 1 not taken.
14459 if(unsigned(id) >= MAXITEMS)
31474 return;
31475 14459 itemdata const& itm = itemsbuf[id];
31476
3/3
✓ Branch 0 taken 14340 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 115 times.
14459 switch(itm.type)
31477 {
31478 case itype_itmbundle:
31479 {
31480
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!itembundle_safe(id, true)) // skip error because it will always have already printed earlier this frame in 'getitem'
31481 break;
31482 24 int ids[10] = {itm.misc1, itm.misc2, itm.misc3, itm.misc4, itm.misc5,
31483 20 itm.misc6, itm.misc7, itm.misc8, itm.misc9, itm.misc10};
31484
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 4 times.
44 for(auto q = 0; q < 10; ++q)
31485 {
31486
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 33 times.
40 if(unsigned(ids[q]) >= MAXITEMS) continue;
31487 33 handle_triforce(scr, ids[q]);
31488 33 }
31489 }
31490 4 break;
31491 case itype_triforcepiece:
31492 {
31493
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 100 times.
115 if(itm.misc2>0)
31494 100 getTriforce(id); //small
31495 15 else getBigTri(scr, id); //big
31496 }
31497 115 break;
31498 }
31499 14459 }
31500
31501 // Attempt to pick up an item. (-1 = check items touching Hero.)
31502 14285105 void HeroClass::checkitems(int32_t index)
31503 {
31504
2/2
✓ Branch 0 taken 1849 times.
✓ Branch 1 taken 14283256 times.
14285105 if(index==-1)
31505 {
31506
2/2
✓ Branch 0 taken 3062608 times.
✓ Branch 1 taken 14283256 times.
17345864 for(auto ind = items.Count()-1; ind >= 0; --ind)
31507 {
31508 3062608 item* itm = (item*)items.spr(ind);
31509
2/2
✓ Branch 0 taken 3062546 times.
✓ Branch 1 taken 62 times.
3062608 if(itm->get_forcegrab())
31510 {
31511 62 checkitems(ind);
31512 62 }
31513 3062608 }
31514
4/6
✓ Branch 0 taken 9737625 times.
✓ Branch 1 taken 4545631 times.
✓ Branch 2 taken 9737625 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9737625 times.
14283256 if(diagonalMovement || NO_GRIDLOCK)
31515 {
31516 4545631 index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,6,6,1);
31517 4545631 }
31518 9737625 else index=items.hit(x,y+(bigHitbox?0:8)-fakez,z,1,1,1);
31519 14283256 }
31520
31521
2/2
✓ Branch 0 taken 120463 times.
✓ Branch 1 taken 14164642 times.
14285105 if(index==-1)
31522 14164642 return;
31523
31524 120463 item* ptr = (item*)items.spr(index);
31525 120463 int32_t pickup = ptr->pickup;
31526 120463 int8_t exstate = ptr->pickupexstate;
31527 120463 int32_t PriceIndex = ptr->PriceIndex;
31528 120463 int32_t id2 = ptr->id;
31529 120463 int32_t holdid = ptr->id;
31530 120463 int32_t pstr = ptr->pstring;
31531 120463 int32_t pstr_flags = ptr->pickup_string_flags;
31532 120463 int32_t linked_parent = ptr->linked_parent;
31533 // `screen_spawned` is probably same as `heroscr`, but could not be if the item moved around.
31534 120463 int32_t item_screen = ptr->screen_spawned;
31535 120463 mapscr* item_scr = get_scr_maybe(cur_map, item_screen);
31536
31537 // I haven't observed this happening, but there are crash reports showing that an
31538 // item sprite does not have a screen_spawned for the current screens.
31539 // Only guess is that `set_forcegrab` kept the item around from the previous screen.
31540 // https://zeldaclassic.sentry.io/share/issue/c13f5a3c5079463fb6901cfea26c695a/
31541
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120463 times.
120463 if (!item_scr)
31542 {
31543 item_screen = get_screen_for_world_xy(ptr->x, ptr->y);
31544 item_scr = get_scr(item_screen);
31545 }
31546
31547 // For items grabbed while in a special screen.
31548
2/2
✓ Branch 0 taken 118898 times.
✓ Branch 1 taken 1565 times.
120463 if (cur_screen >= 128)
31549 1565 item_scr = special_warp_return_scr;
31550
31551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120463 times.
120463 if(ptr->fallclk > 0) return; //Don't pick up a falling item
31552
31553
1/2
✓ Branch 0 taken 120463 times.
✗ Branch 1 not taken.
120463 if(itemsbuf[id2].type == itype_progressive_itm)
31554 {
31555 int32_t newid = get_progressive_item(id2);
31556 if(newid > -1)
31557 {
31558 id2 = newid;
31559 holdid = newid;
31560 pstr = itemsbuf[newid].pstring;
31561 pstr_flags = itemsbuf[newid].pickup_string_flags;
31562 }
31563 }
31564
31565
2/2
✓ Branch 0 taken 119437 times.
✓ Branch 1 taken 1026 times.
120463 bool bottledummy = (pickup&ipCHECK) && item_scr->room == rBOTTLESHOP;
31566
31567
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 120430 times.
120463 if(bottledummy) //Dummy bullshit!
31568 {
31569
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!game->canFillBottle())
31570 return;
31571
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
31572 {
31573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!current_item_power(itype_wallet))
31574 {
31575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
31576 1 int32_t tmpprice = -abs(prices[PriceIndex]);
31577 //game->change_drupy(-abs(prices[priceindex]));
31578 1 int32_t total = game->get_drupy()-tmpprice;
31579 1 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
31580 1 game->set_drupy(game->get_drupy()-total);
31581 1 }
31582 else //infinite wallet
31583 {
31584 game->change_drupy(0);
31585 }
31586 1 }
31587 33 boughtsomething=true;
31588 //make the other shop items untouchable after
31589 //you buy something
31590
31591
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 33 times.
37 for(int32_t i=0; i<items.Count(); i++)
31592 {
31593
4/4
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
4 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
31594 2 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
31595 4 }
31596
31597 33 int32_t slot = game->fillBottle(QMisc.bottle_shop_types[item_scr->catchall].fill[PriceIndex]);
31598 33 id2 = find_bottle_for_slot(slot);
31599 33 ptr->id = id2;
31600 33 holdid = id2;
31601 33 pstr = 0;
31602 33 pickup |= ipHOLDUP;
31603 33 }
31604 else
31605 {
31606
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120430 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120430 if(itemsbuf[id2].type == itype_bottlefill && !game->canFillBottle())
31607 return; //No picking these up unless you have a bottle to fill!
31608
31609
5/6
✓ Branch 0 taken 115173 times.
✓ Branch 1 taken 5257 times.
✓ Branch 2 taken 103751 times.
✓ Branch 3 taken 11422 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 103751 times.
120430 if(((pickup&ipTIMER) && (ptr->clk2 < 32))&& !(pickup & ipCANGRAB))
31610
2/2
✓ Branch 0 taken 103546 times.
✓ Branch 1 taken 205 times.
103751 if(ptr->id!=iFairyMoving)
31611 // wait for it to stop flashing, doesn't check for other items yet
31612 103546 return;
31613
31614
2/2
✓ Branch 0 taken 16827 times.
✓ Branch 1 taken 57 times.
16884 if(pickup&ipENEMY) // item was being carried by enemy
31615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
114 if(more_carried_items(item_screen)<=1) // 1 includes this own item.
31616 57 screen_item_set_state(item_screen, ScreenItemState::None);
31617
31618
2/2
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 15181 times.
16884 if(pickup&ipDUMMY) // dummy item (usually a rupee)
31619 {
31620
2/2
✓ Branch 0 taken 1640 times.
✓ Branch 1 taken 63 times.
1703 if(pickup&ipMONEY)
31621 63 dospecialmoney(item_scr, index);
31622
31623 1703 return;
31624 }
31625
31626
3/4
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 15086 times.
✓ Branch 2 taken 95 times.
✗ Branch 3 not taken.
15181 if(get_qr(qr_HEARTSREQUIREDFIX) && !canget(id2))
31627 return;
31628
31629 15181 int32_t nextitem = -1;
31630 15181 do
31631 {
31632 15181 nextitem = -1;
31633
4/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 15156 times.
✓ Branch 2 taken 11 times.
✓ Branch 3 taken 14 times.
15181 if((itemsbuf[id2].flags & item_combine) && game->get_item(id2))
31634 // Item upgrade routine.
31635 {
31636
31637
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 14 times.
3598 for(int32_t i=0; i<MAXITEMS; i++)
31638 {
31639 // Find the item which is as close to this item's fam_type as possible.
31640
4/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 3553 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 14 times.
3584 if(itemsbuf[i].type==itemsbuf[id2].type && itemsbuf[i].level>itemsbuf[id2].level
31641
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
31 && (nextitem>-1 ? itemsbuf[i].level<=itemsbuf[nextitem].level : true))
31642 {
31643 14 nextitem = i;
31644 14 }
31645 3584 }
31646
31647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(nextitem>-1)
31648 {
31649 14 id2 = nextitem;
31650
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(get_qr(qr_ITEMCOMBINE_NEW_PSTR))
31651 {
31652 pstr = itemsbuf[id2].pstring;
31653 pstr_flags = itemsbuf[id2].pickup_string_flags;
31654 }
31655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(!get_qr(qr_ITEMCOMBINE_CONTINUOUS))
31656 14 break; //no looping
31657 }
31658 }
31659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15167 times.
15167 } while(nextitem > -1);
31660
31661
2/2
✓ Branch 0 taken 14156 times.
✓ Branch 1 taken 1025 times.
15181 if(pickup&ipCHECK) // check restrictions
31662
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 209 times.
✓ Branch 3 taken 107 times.
1025 switch(item_scr->room)
31663 {
31664 case rSP_ITEM: // special item
31665
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 63 times.
209 if(!canget(id2)) // These ones always need the Hearts Required check
31666 63 return;
31667
31668 146 break;
31669
31670 case rP_SHOP: // potion shop
31671
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 14 times.
107 if(msg_active)
31672 93 return;
31673 [[fallthrough]];
31674 case rSHOP: // shop
31675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
723 if(prices[PriceIndex]!=100000) // 100000 is a placeholder price for free items
31676 {
31677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 723 times.
723 if(!current_item_power(itype_wallet))
31678 {
31679
2/2
✓ Branch 0 taken 600 times.
✓ Branch 1 taken 123 times.
723 if( game->get_spendable_rupies()<abs(prices[PriceIndex]) ) return;
31680 123 int32_t tmpprice = -abs(prices[PriceIndex]);
31681 //game->change_drupy(-abs(prices[priceindex]));
31682 123 int32_t total = game->get_drupy()-tmpprice;
31683 123 total = vbound(total, 0, game->get_maxcounter(1)); //Never overflow! Overflow here causes subscreen bugs! -Z
31684 123 game->set_drupy(game->get_drupy()-total);
31685 123 }
31686 else //infinite wallet
31687 {
31688 game->change_drupy(0);
31689 }
31690 123 }
31691 123 boughtsomething=true;
31692 //make the other shop items untouchable after
31693 //you buy something
31694 123 int32_t count = 0;
31695
31696
2/2
✓ Branch 0 taken 369 times.
✓ Branch 1 taken 123 times.
492 for(int32_t i=0; i<3; i++)
31697 {
31698
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 324 times.
369 if(QMisc.shop[item_scr->catchall].hasitem[i] != 0)
31699 {
31700 324 ++count;
31701 324 }
31702 369 }
31703
31704
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 123 times.
573 for(int32_t i=0; i<items.Count(); i++)
31705 {
31706
4/4
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 126 times.
✓ Branch 2 taken 123 times.
✓ Branch 3 taken 201 times.
450 if(((item*)items.spr(i))->PriceIndex >-1 && i!=index)
31707 201 ((item*)items.spr(i))->pickup=ipDUMMY+ipFADE;
31708 450 }
31709
31710 123 break;
31711 269 }
31712
31713 //EVENT
31714 {
31715 14425 std::vector<int32_t> &ev = FFCore.eventData;
31716 14425 ev.clear();
31717 14425 ev.push_back(id2*10000);
31718 14425 ev.push_back(pickup*10000);
31719 14425 ev.push_back(pstr*10000);
31720 14425 ev.push_back(pstr_flags*10000);
31721 14425 ev.push_back(0);
31722 14425 ev.push_back(ptr->getUID());
31723 14425 ev.push_back(GENEVT_ICTYPE_COLLECT*10000);
31724 14425 ev.push_back(0);
31725
31726 14425 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
31727 14425 bool nullify = ev[4] != 0;
31728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14425 times.
14425 if(nullify) return;
31729 14425 id2 = ev[0]/10000;
31730 14425 pickup = (pickup&(ipCHECK|ipDUMMY)) | (ev[1]/10000);
31731 14425 pstr = ev[2] / 10000;
31732 14425 pstr_flags = ev[3] / 10000;
31733 }
31734
31735
2/2
✓ Branch 0 taken 1557 times.
✓ Branch 1 taken 12868 times.
14425 if(pickup&ipONETIME) // set mITEM for one-time-only items
31736 {
31737 1557 setmapflag(item_scr, mITEM);
31738
31739 //Okay so having old source files is a godsend. You wanna know why?
31740 //Because the issue here was never to so with the wrong flag being set; no it's always been setting the right flag.
31741 //The problem here is that guy rooms were always checking for getmapflag, which used to have an internal check for the default.
31742 //The default would be mITEM if cur_screen was under 128 (AKA not in a cave), and mSPECIALITEM if in a cave.
31743 //However, now the check just always defaults to mSPECIALITEM, which causes this bug.
31744 //This means that this section of code is no longer a bunch of eggshells, cause none of these overcomplicated compats actually solved shit lmao - Dimi
31745
31746 /*
31747 // WARNING - Item pickups are very volatile due to crazy compatability hacks, eg., supporting
31748 // broken behavior from early ZC versions. If you change things here please comment on its purpose.
31749
31750 // some old quests need picking up a screen item to also disable the BELOW flag (for hunger rooms, etc)
31751 // What is etc?! We need to check for every valid state here. ~Gleeok
31752 if(get_qr(qr_ITEMPICKUPSETSBELOW))
31753 {
31754 // Most older quests need one-time-pickups to not remove special items, etc.
31755 if(origin_scr->room==rGRUMBLE)
31756 {
31757 setmapflag(mSPECIALITEM);
31758 }
31759 }
31760 */
31761 1557 }
31762
2/2
✓ Branch 0 taken 12102 times.
✓ Branch 1 taken 766 times.
12868 else if(pickup&ipONETIME2) // set mSPECIALITEM flag for other one-time-only items
31763
2/2
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 504 times.
766 setmapflag(item_scr, (cur_screen < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
31764
31765
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 14423 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
14425 if(exstate > -1 && exstate < 32)
31766 {
31767 2 setxmapflag(item_screen, 1<<exstate);
31768 2 }
31769
31770
2/2
✓ Branch 0 taken 14424 times.
✓ Branch 1 taken 1 times.
14425 if(pickup&ipSECRETS) // Trigger secrets if this item has the secret pickup
31771 {
31772
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (item_scr->flags9&fITEMSECRETPERM) setmapflag(item_scr, mSECRET);
31773 1 trigger_secrets_for_screen(TriggerSource::ItemsSecret, item_scr, false);
31774 1 }
31775
31776 14425 collectitem_script(id2);
31777 14425 getitem(id2, ptr->noSound, true);
31778 }
31779
31780
2/2
✓ Branch 0 taken 1561 times.
✓ Branch 1 taken 12893 times.
14458 if(pickup&ipHOLDUP)
31781 {
31782 1561 attackclk=0;
31783 1561 reset_swordcharge();
31784
31785
3/4
✓ Branch 0 taken 1516 times.
✓ Branch 1 taken 45 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1516 times.
1561 if(action!=swimming && !IsSideSwim())
31786 1516 reset_hookshot();
31787
31788
2/2
✓ Branch 0 taken 1201 times.
✓ Branch 1 taken 280 times.
1561 if(msg_onscreen)
31789 {
31790 280 dismissmsg();
31791 280 }
31792
31793 1481 clear_bitmap(pricesdisplaybuf);
31794
31795
7/8
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 1323 times.
✓ Branch 2 taken 90 times.
✓ Branch 3 taken 68 times.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 66 times.
✓ Branch 7 taken 144 times.
1528 if(get_qr(qr_OLDPICKUP) || ((item_scr->room==rSP_ITEM || item_scr->room==rRP_HC || item_scr->room==rTAKEONE) && (pickup&ipONETIME2)) ||
31796
4/4
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 46 times.
✓ Branch 3 taken 1 times.
144 (get_qr(qr_SHOP_ITEMS_VANISH) && (item_scr->room==rBOTTLESHOP || item_scr->room==rSHOP) && (pickup&ipCHECK)))
31797 {
31798 1436 fadeclk=66;
31799 1436 }
31800
31801
5/6
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 1511 times.
✓ Branch 2 taken 22 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 12 times.
1533 if(id2!=iBombs || action==swimming || get_qr(qr_BOMBHOLDFIX))
31802 {
31803 // don't hold up bombs unless swimming or the bomb hold fix quest rule is on
31804
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1504 times.
1521 if(action==swimming)
31805 {
31806 17 action=waterhold1; FFCore.setHeroAction(waterhold1);
31807 17 }
31808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1504 times.
1504 else if(IsSideSwim())
31809 {
31810 action=sidewaterhold1; FFCore.setHeroAction(sidewaterhold1);
31811 }
31812 else
31813 {
31814 1504 action=landhold1; FFCore.setHeroAction(landhold1);
31815 }
31816
31817
2/2
✓ Branch 0 taken 1168 times.
✓ Branch 1 taken 353 times.
1521 if(ptr->twohand)
31818 {
31819
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 347 times.
353 if(action==waterhold1)
31820 {
31821 6 action=waterhold2; FFCore.setHeroAction(waterhold2);
31822 6 }
31823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 347 times.
347 else if(action==sidewaterhold1)
31824 {
31825 action=sidewaterhold2; FFCore.setHeroAction(sidewaterhold2);
31826 }
31827 else
31828 {
31829 347 action=landhold2; FFCore.setHeroAction(landhold2);
31830 }
31831 353 }
31832
31833 1521 holdclk=130;
31834
31835 //restart music
31836
2/2
✓ Branch 0 taken 1411 times.
✓ Branch 1 taken 110 times.
1521 if(get_qr(qr_HOLDNOSTOPMUSIC) == 0)
31837 110 music_stop();
31838
31839 1521 holditem=holdid; // NES consistency: when combining blue potions, hold up the blue potion.
31840 1521 freeze_guys=true;
31841 //show the info string
31842
31843
31844 //if (pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || itemsbuf[index].pickup_string_flags&itemdataPSTRING_IP_HOLDUP ) ) )
31845
31846 1521 int32_t shop_pstr = 0;
31847
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 1379 times.
1521 if (PriceIndex > -1)
31848 {
31849
3/3
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 109 times.
✓ Branch 2 taken 1 times.
142 switch(item_scr->room)
31850 {
31851 case rSHOP:
31852 109 shop_pstr = QMisc.shop[item_scr->catchall].str[PriceIndex];
31853 109 break;
31854 case rBOTTLESHOP:
31855 1 shop_pstr = QMisc.bottle_shop_types[item_scr->catchall].str[PriceIndex];
31856 1 break;
31857 }
31858 142 }
31859
5/6
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1502 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1501 times.
1521 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
31860 {
31861
9/12
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✓ Branch 9 taken 4 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 14 times.
20 if ( (pstr > 0 && pstr < msg_count) && ( ( ( pstr_flags&itemdataPSTRING_ALWAYS || pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_IP_HOLDUP || (!(FFCore.GetItemMessagePlayed(id2))) ) ) ) )
31862 {
31863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
31864 19 }
31865 1 else pstr = 0;
31866
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 19 times.
20 if(shop_pstr)
31867 {
31868 1 donewmsg(item_scr, shop_pstr);
31869 1 enqueued_str = pstr;
31870 1 }
31871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 else if(pstr)
31872 {
31873 19 donewmsg(item_scr, pstr);
31874 19 }
31875 20 }
31876
31877 1521 }
31878
31879
4/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1429 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4 times.
1533 if(itemsbuf[id2].type!=itype_triforcepiece || !(itemsbuf[id2].flags & item_gamedata))
31880 {
31881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1433 times.
1433 if (!ptr->noHoldSound) sfx(item_scr->holdupsfx);
31882 1433 }
31883
31884 1533 ptr->set_forcegrab(false);
31885 1533 items.del(index);
31886
31887
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 1533 times.
1760 for(int32_t i=0; i<Lwpns.Count(); i++)
31888 {
31889 227 weapon *w = (weapon*)Lwpns.spr(i);
31890
31891
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 227 times.
227 if(w->dragging==index)
31892 {
31893 w->dragging=-1;
31894 }
31895
1/2
✓ Branch 0 taken 227 times.
✗ Branch 1 not taken.
227 else if(w->dragging>index)
31896 {
31897 w->dragging-=1;
31898 }
31899 227 }
31900
31901 // clear up shop stuff
31902
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 689 times.
✓ Branch 2 taken 717 times.
✓ Branch 3 taken 127 times.
1533 if((isdungeon()==0)&&(index!=0))
31903 {
31904
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 83 times.
127 if(boughtsomething)
31905 {
31906 83 fadeclk=66;
31907
31908
3/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
83 if(((item*)items.spr(0))->id == iRupy && ((item*)items.spr(0))->pickup & ipDUMMY)
31909 {
31910 80 items.del(0);
31911
31912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 for(int32_t i=0; i<Lwpns.Count(); i++)
31913 {
31914 weapon *w = (weapon*)Lwpns.spr(i);
31915
31916 if(w->dragging==0)
31917 {
31918 w->dragging=-1;
31919 }
31920 else if(w->dragging>0)
31921 {
31922 w->dragging-=1;
31923 }
31924 }
31925 80 }
31926 83 }
31927
31928
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 if(msg_onscreen)
31929 {
31930 dismissmsg();
31931 }
31932
31933 127 clear_bitmap(pricesdisplaybuf);
31934 127 set_clip_state(pricesdisplaybuf, 1);
31935 127 }
31936
31937 // items.del(index);
31938 1533 }
31939 else
31940 {
31941 12893 ptr->set_forcegrab(false);
31942 12893 items.del(index);
31943
31944
2/2
✓ Branch 0 taken 9184 times.
✓ Branch 1 taken 12893 times.
22077 for(int32_t i=0; i<Lwpns.Count(); i++)
31945 {
31946 9184 weapon *w = (weapon*)Lwpns.spr(i);
31947
31948
2/2
✓ Branch 0 taken 490 times.
✓ Branch 1 taken 8694 times.
9184 if(w->dragging==index)
31949 {
31950 490 w->dragging=-1;
31951 490 }
31952
2/2
✓ Branch 0 taken 8690 times.
✓ Branch 1 taken 4 times.
8694 else if(w->dragging>index)
31953 {
31954 4 w->dragging-=1;
31955 4 }
31956 9184 }
31957
31958
2/2
✓ Branch 0 taken 12880 times.
✓ Branch 1 taken 13 times.
12893 if(msg_onscreen)
31959 {
31960 13 dismissmsg();
31961 13 }
31962
31963 //general item pickup message
31964 //show the info string
31965 //non-held
31966 //if ( pstr > 0 ) //&& itemsbuf[index].pstring < msg_count && ( ( itemsbuf[index].pickup_string_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(index))) ) ) )
31967
3/6
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 12757 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 136 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
12893 int32_t shop_pstr = ( item_scr->room == rSHOP && PriceIndex>=0 && QMisc.shop[item_scr->catchall].str[PriceIndex] > 0 ) ? QMisc.shop[item_scr->catchall].str[PriceIndex] : 0;
31968
4/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12891 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12891 times.
12893 if ( (pstr > 0 && pstr < msg_count) || (shop_pstr > 0 && shop_pstr < msg_count) )
31969 {
31970
7/12
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 1 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 times.
2 if ( (pstr > 0 && pstr < msg_count) && ( (!(pstr_flags&itemdataPSTRING_IP_HOLDUP)) && ( pstr_flags&itemdataPSTRING_NOMARK || pstr_flags&itemdataPSTRING_ALWAYS || (!(FFCore.GetItemMessagePlayed(id2))) ) ) )
31971 {
31972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( (!(pstr_flags&itemdataPSTRING_NOMARK)) ) FFCore.SetItemMessagePlayed(id2);
31973 1 }
31974 1 else pstr = 0;
31975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(shop_pstr)
31976 {
31977 donewmsg(item_scr, shop_pstr);
31978 enqueued_str = pstr;
31979 }
31980
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
2 else if(pstr)
31981 {
31982 1 donewmsg(item_scr, pstr);
31983 1 }
31984 2 }
31985
31986
31987 12893 clear_bitmap(pricesdisplaybuf);
31988 12893 set_clip_state(pricesdisplaybuf, 1);
31989 }
31990
31991
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11 times.
14441 if(itemsbuf[id2].type==itype_triforcepiece
31992
4/4
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 14311 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 100 times.
14426 && itemsbuf[id2].misc2 <= 0 && linked_parent == eeGANON)
31993 {
31994 11 game->lvlitems[dlevel]|=liBOSS;
31995 11 }
31996 14426 handle_triforce(item_scr, id2);
31997
2/2
✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 12980 times.
14426 if(!holdclk)
31998 12980 post_item_collect();
31999 14285073 }
32000
32001 294 void HeroClass::StartRefill(int32_t refillWhat)
32002 {
32003
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 276 times.
294 if(FFCore.quest_format[vZelda] < 0x255)
32004 {
32005 //Yes, this isn't a QR check. This was implemented before the QRs got bumped up.
32006 //I attempted to change this check to a quest rule, but here's the issue: this affects
32007 //triforces and potions as well, not just fairy flags. This means that having a compat rule
32008 //would result in a rule that is checked by default for every tileset or quest made before
32009 //2.55, one in a place most people won't check. That means that if they were to go to use
32010 //the new potion or triforce flags for jinx curing behavior, they'd find that it doesn't work,
32011 //all because of an obscure compat rule being checked. Most peoples instincts are sadly not
32012 //"go through the compat rules and turn them all off", so this remains a version check instead
32013 //of a qr check. Don't make my mistake and waste time trying to change this in vain. -Deedee
32014 276 Start250Refill(refillWhat);
32015 276 return;
32016 }
32017
32018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if(!refilling)
32019 {
32020 18 refillclk=21;
32021 18 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
32022 18 sfx(WAV_REFILL,128,true);
32023 18 refilling=refillWhat;
32024
32025
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 9 times.
18 if(refill_why>=0) // Item index
32026 {
32027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].type==itype_potion)
32028 {
32029 if(itemsbuf[refill_why].flags & item_flag3){swordclk=0;verifyAWpn();}
32030 if(itemsbuf[refill_why].flags & item_flag4)itemclk=0;
32031 if(itemsbuf[refill_why].flags & item_flag5)shieldjinxclk=0;
32032 }
32033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(itemsbuf[refill_why].type==itype_triforcepiece)
32034 {
32035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & item_flag3){swordclk=0;verifyAWpn();}
32036
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & item_flag4)itemclk=0;
32037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(itemsbuf[refill_why].flags & item_flag5)shieldjinxclk=0;
32038 9 }
32039 9 }
32040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 else if(refill_why==REFILL_FAIRY)
32041 {
32042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!get_qr(qr_NONBUBBLEFAIRIES)){swordclk=0;verifyAWpn();}
32043
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7 times.
9 if(get_qr(qr_ITEMBUBBLE))itemclk=0;
32044
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(get_qr(qr_SHIELDBUBBLE))shieldjinxclk=0;
32045 9 }
32046 18 }
32047 294 }
32048
32049 276 void HeroClass::Start250Refill(int32_t refillWhat)
32050 {
32051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 276 times.
276 if(!refilling)
32052 {
32053 276 refillclk=21;
32054 276 stop_sfx(QMisc.miscsfx[sfxLOWHEART]);
32055 276 sfx(WAV_REFILL,128,true);
32056 276 refilling=refillWhat;
32057
32058 // For ~2 years <2.55 quests were broken, never restoring anything on fairies.
32059 // https://discord.com/channels/876899628556091432/1275805052006563861
32060
2/4
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
276 if (replay_is_active() && replay_version_check(0, 35))
32061 {
32062
2/4
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 276 times.
✗ Branch 3 not taken.
276 std::string qst = replay_get_meta_str("qst");
32063
9/12
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 229 times.
✓ Branch 3 taken 47 times.
✓ Branch 4 taken 229 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 201 times.
✓ Branch 7 taken 28 times.
✓ Branch 8 taken 201 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 23 times.
✓ Branch 11 taken 178 times.
276 if (qst == "first_quest_layered.qst" || qst == "nes_remastered.qst" || qst == "demosp253.qst")
32064 98 return;
32065
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 178 times.
276 }
32066
32067
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 92 times.
178 if(refill_why>=0) // Item index
32068 {
32069
4/4
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 71 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 7 times.
86 if((itemsbuf[refill_why].type==itype_potion)&&(!get_qr(qr_NONBUBBLEMEDICINE)))
32070 {
32071 7 swordclk=0;
32072 7 verifyAWpn();
32073
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
32074 7 }
32075
32076
4/4
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 57 times.
86 if((itemsbuf[refill_why].type==itype_triforcepiece)&&(!get_qr(qr_NONBUBBLETRIFORCE)))
32077 {
32078 57 swordclk=0;
32079 57 verifyAWpn();
32080
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1 times.
57 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
32081 57 }
32082 86 }
32083
3/4
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 54 times.
92 else if((refill_why==REFILL_FAIRY)&&(!get_qr(qr_NONBUBBLEFAIRIES)))
32084 {
32085 54 swordclk=0;
32086 54 verifyAWpn();
32087
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(get_qr(qr_ITEMBUBBLE)) itemclk=0;
32088 54 }
32089 178 }
32090 276 }
32091
32092 377716 bool HeroClass::refill()
32093 {
32094
4/4
✓ Branch 0 taken 22058 times.
✓ Branch 1 taken 355658 times.
✓ Branch 2 taken 636 times.
✓ Branch 3 taken 21422 times.
377716 if(refilling==REFILL_NONE || refilling==REFILL_FAIRYDONE)
32095 {
32096 356294 return false;
32097 }
32098
32099 21422 ++refillclk;
32100 21422 int32_t speed = get_qr(qr_FASTFILL) ? 6 : 22;
32101 21422 int32_t refill_heart_stop=game->get_maxlife();
32102 21422 int32_t refill_magic_stop=game->get_maxmagic();
32103
32104
4/4
✓ Branch 0 taken 10865 times.
✓ Branch 1 taken 10557 times.
✓ Branch 2 taken 4542 times.
✓ Branch 3 taken 6323 times.
21422 if(refill_why>=0 && itemsbuf[refill_why].type==itype_potion)
32105 {
32106
2/6
✓ Branch 0 taken 6323 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6323 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6323 refill_heart_stop=zc_min(potion_life+(itemsbuf[refill_why].flags & item_flag1 ?int32_t(game->get_maxlife()*(itemsbuf[refill_why].misc1 /100.0)):((itemsbuf[refill_why].misc1 *game->get_hp_per_heart()))),game->get_maxlife());
32107
2/6
✓ Branch 0 taken 6323 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6323 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6323 refill_magic_stop=zc_min(potion_magic+(itemsbuf[refill_why].flags & item_flag2 ?int32_t(game->get_maxmagic()*(itemsbuf[refill_why].misc2 /100.0)):((itemsbuf[refill_why].misc2 *game->get_mp_per_block()))),game->get_maxmagic());
32108 6323 }
32109
32110
2/2
✓ Branch 0 taken 18948 times.
✓ Branch 1 taken 2474 times.
21422 if(refillclk%speed == 0)
32111 {
32112 // game->life&=0xFFC;
32113
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1194 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 1277 times.
2474 switch(refill_what)
32114 {
32115 case REFILL_LIFE:
32116
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 1139 times.
1194 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
32117
32118
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 1038 times.
1194 if(game->get_life()>=refill_heart_stop)
32119 {
32120 156 game->set_life(refill_heart_stop);
32121 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
32122
2/2
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 156 times.
40092 for ( int32_t q = 0; q < WAV_COUNT; q++ )
32123 {
32124
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 39780 times.
39936 if ( q == (int32_t)hero_scr->oceansfx ) continue;
32125
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 39779 times.
39780 if ( q == (int32_t)hero_scr->bosssfx ) continue;
32126 39779 stop_sfx(q);
32127 39779 }
32128 156 sfx(QMisc.miscsfx[sfxREFILL]);
32129 156 refilling=REFILL_NONE;
32130 156 return false;
32131 }
32132
32133 1038 break;
32134
32135 case REFILL_MAGIC:
32136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
32137
32138
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
3 if(game->get_magic()>=refill_magic_stop)
32139 {
32140 1 game->set_magic(refill_magic_stop);
32141 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
32142
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for ( int32_t q = 0; q < WAV_COUNT; q++ )
32143 {
32144
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 255 times.
256 if ( q == (int32_t)hero_scr->oceansfx ) continue;
32145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 if ( q == (int32_t)hero_scr->bosssfx ) continue;
32146 255 stop_sfx(q);
32147 255 }
32148 1 sfx(QMisc.miscsfx[sfxREFILL]);
32149 1 refilling=REFILL_NONE;
32150 1 return false;
32151 }
32152
32153 2 break;
32154
32155 case REFILL_ALL:
32156
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 1181 times.
1277 game->set_life(zc_min(refill_heart_stop, (game->get_life()+game->get_hp_per_heart()/2)));
32157
2/2
✓ Branch 0 taken 1187 times.
✓ Branch 1 taken 90 times.
1277 game->set_magic(zc_min(refill_magic_stop, (game->get_magic()+game->get_mp_per_block()/4)));
32158
32159
4/4
✓ Branch 0 taken 158 times.
✓ Branch 1 taken 1119 times.
✓ Branch 2 taken 137 times.
✓ Branch 3 taken 21 times.
1277 if((game->get_life()>=refill_heart_stop)&&(game->get_magic()>=refill_magic_stop))
32160 {
32161 137 game->set_life(refill_heart_stop);
32162 137 game->set_magic(refill_magic_stop);
32163 //kill_sfx(); //this 1. needs to be pause resme, and 2. needs an item flag.
32164
2/2
✓ Branch 0 taken 35072 times.
✓ Branch 1 taken 137 times.
35209 for ( int32_t q = 0; q < WAV_COUNT; q++ )
32165 {
32166
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 34935 times.
35072 if ( q == (int32_t)hero_scr->oceansfx ) continue;
32167
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 34915 times.
34935 if ( q == (int32_t)hero_scr->bosssfx ) continue;
32168 34915 stop_sfx(q);
32169 34915 }
32170 137 sfx(QMisc.miscsfx[sfxREFILL]);
32171 137 refilling=REFILL_NONE;
32172 137 return false;
32173 }
32174
32175 1140 break;
32176 }
32177 2180 }
32178
32179 21128 return true;
32180 377716 }
32181
32182 100 void HeroClass::getTriforce(int32_t id2)
32183 {
32184
32185 PALETTE flash_pal;
32186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 int32_t refill_frame = ( (itemsbuf[id2].misc5 > 0) ? itemsbuf[id2].misc5 : 88 );
32187
32188
2/2
✓ Branch 0 taken 25600 times.
✓ Branch 1 taken 100 times.
25700 for(int32_t i=0; i<256; i++)
32189 {
32190
2/2
✓ Branch 0 taken 15616 times.
✓ Branch 1 taken 9984 times.
25600 flash_pal[i] = get_qr(qr_FADE) ? _RGB(255,255,0) : _RGB(255,255,255);
32191 25600 }
32192
32193
32194
32195 //get rid off all sprites but Hero
32196 100 guys.clear();
32197 100 items.clear();
32198 100 Ewpns.clear();
32199 100 Lwpns.clear();
32200 100 chainlinks.clear();
32201
32202 100 kill_subscr_items();
32203
32204 100 sfx(itemsbuf[id2].playsound);
32205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if ( !(itemsbuf[id2].flags & item_flag11) ) music_stop();
32206
32207 //If item flag six is enabled, and a sound is set to attributes[2], play that sound.
32208
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if ( (itemsbuf[id2].flags & item_flag14) )
32209 {
32210 uint8_t playwav = itemsbuf[id2].misc3;
32211 sfx(playwav);
32212
32213 }
32214
32215 //itemsbuf[id2].flags & item_flag9 : Don't dismiss Messages
32216 //itemsbuf[id2].flags & item_flag10 : Cutscene interrupts action script..
32217 //itemsbuf[id2].flags & item_flag11 : Don't change music.
32218 //itemsbuf[id2].flags & item_flag12 : Run Collect Script Script On Collection
32219 //itemsbuf[id2].flags & item_flag13 : Run Action Script On Collection
32220 //itemsbuf[id2].flags & item_flag14 : Play second sound (WAV) from Attributes[2] (misc2)
32221 //itemsbuf[id2].flags & item_flag15 : No MIDI
32222
32223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!(itemsbuf[id2].flags & item_flag15)) //No MIDI flag
32224 {
32225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(itemsbuf[id2].misc1)
32226 jukebox(itemsbuf[id2].misc1+ZC_MIDI_COUNT-1);
32227 else
32228 100 try_zcmusic("zelda.nsf",qstpath,5,ZC_MIDI_TRIFORCE,get_emusic_volume());
32229 100 }
32230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(itemsbuf[id2].flags & item_gamedata)
32231 {
32232 100 game->lvlitems[dlevel]|=liTRIFORCE;
32233 100 }
32234
32235 100 int32_t f=0;
32236 100 int32_t x2=0;
32237 100 int32_t curtain_x=0;
32238 100 int32_t c=0;
32239
32240 100 do
32241 {
32242
32243
32244
1/2
✓ Branch 0 taken 52360 times.
✗ Branch 1 not taken.
52360 if ( (itemsbuf[id2].flags & item_flag13) ) //Run action script on collection.
32245 {
32246 if ( itemsbuf[id2].script )
32247 {
32248 if ( !FFCore.doscript(ScriptType::Item, id2) )
32249 {
32250 int i = id2;
32251 FFCore.reset_script_engine_data(ScriptType::Item, i);
32252 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, i);
32253 FFCore.deallocateAllScriptOwned(ScriptType::Item, i);
32254 }
32255 else
32256 {
32257 if ( !(itemsbuf[id2].flags & item_flag10) ) //Cutscene halts the script it resumes after cutscene.
32258 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[id2].script, id2); //if flag is off, run the script every frame of the cutscene.
32259 }
32260 }
32261 }
32262 //if ( itemsbuf[id2].misc2 == 2 ) //No cutscene; what if people used '2' on older quests?
32263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if ( (itemsbuf[id2].flags & item_flag12) ) //No cutscene
32264 {
32265 return;
32266 }
32267
32268
2/2
✓ Branch 0 taken 32594 times.
✓ Branch 1 taken 19766 times.
52360 if(!COOLSCROLL)
32269 {
32270 19766 show_subscreen_items=false;
32271 19766 }
32272
32273
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
52360 if(f==40)
32274 {
32275 100 actiontype oldaction = action;
32276 100 ALLOFF((!(itemsbuf[id2].flags & item_flag9)), false);
32277 100 action=oldaction; // have to reset this flag
32278 100 FFCore.setHeroAction(oldaction);
32279 100 }
32280
32281
32282
4/4
✓ Branch 0 taken 48360 times.
✓ Branch 1 taken 4000 times.
✓ Branch 2 taken 43560 times.
✓ Branch 3 taken 4800 times.
52360 if(f>=40 && f<88)
32283 {
32284
2/2
✓ Branch 0 taken 2928 times.
✓ Branch 1 taken 1872 times.
4800 if(get_qr(qr_FADE))
32285 {
32286
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2928 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2928 if (!flash_reduction_enabled() && (f&7) == 0)
32287 {
32288 fade_interpolate(RAMpal,flash_pal,RAMpal,42,0,CSET(6)-1);
32289 refreshpal=true;
32290 }
32291
32292
2/2
✓ Branch 0 taken 2196 times.
✓ Branch 1 taken 732 times.
2928 if((f&3)==2)
32293 {
32294 732 loadpalset(0,0);
32295 732 loadpalset(1,1);
32296 732 loadpalset(5,5);
32297
32298
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 12 times.
732 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
32299 12 else loadlvlpal(0xB); // TODO: Cave/Item Cellar distinction?
32300 732 }
32301 2928 }
32302 else
32303 {
32304
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1872 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1872 if(!flash_reduction_enabled() && (f&7) == 0)
32305 {
32306 for(int32_t cs2=2; cs2<5; cs2++)
32307 {
32308 for(int32_t i=1; i<16; i++)
32309 {
32310 RAMpal[CSET(cs2)+i]=flash_pal[CSET(cs2)+i];
32311 }
32312 }
32313
32314 refreshpal=true;
32315 }
32316
32317
2/2
✓ Branch 0 taken 1638 times.
✓ Branch 1 taken 234 times.
1872 if((f&7)==4)
32318 {
32319
1/2
✓ Branch 0 taken 234 times.
✗ Branch 1 not taken.
234 if(cur_screen<128) loadlvlpal(DMaps[cur_dmap].color);
32320 else loadlvlpal(0xB);
32321
32322 234 loadpalset(5,5);
32323 234 }
32324 }
32325 4800 }
32326
32327
32328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if(itemsbuf[id2].flags & item_gamedata)
32329 {
32330
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
52360 if(f==refill_frame)
32331 {
32332 100 refill_what=REFILL_ALL;
32333 100 refill_why=id2;
32334 100 StartRefill(REFILL_ALL);
32335 100 refill();
32336 100 }
32337
32338
2/2
✓ Branch 0 taken 47900 times.
✓ Branch 1 taken 4460 times.
52360 if(f==(refill_frame+1))
32339 {
32340
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 4360 times.
4460 if(refill())
32341 {
32342 4360 --f;
32343 4360 }
32344 4460 }
32345 52360 }
32346
32347
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 if(itemsbuf[id2].flags & item_flag1) // Warp out flag
32348 {
32349
4/4
✓ Branch 0 taken 27200 times.
✓ Branch 1 taken 25160 times.
✓ Branch 2 taken 19200 times.
✓ Branch 3 taken 8000 times.
52360 if(f>=208 && f<288)
32350 {
32351 8000 ++x2;
32352
32353
3/3
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 1600 times.
8000 switch(++c)
32354 {
32355 case 5:
32356 1600 c=0;
32357 [[fallthrough]];
32358 case 0:
32359 case 2:
32360 case 3:
32361 4800 ++x2;
32362 4800 break;
32363 }
32364 8000 }
32365
32366 52360 do_dcounters();
32367
32368
2/2
✓ Branch 0 taken 19200 times.
✓ Branch 1 taken 33160 times.
52360 if(f<288)
32369 {
32370 33160 curtain_x=TRUNCATE_HALF_TILE(x2);
32371 33160 draw_screen_clip_rect_x1=curtain_x;
32372 33160 draw_screen_clip_rect_x2=255-curtain_x;
32373 33160 draw_screen_clip_rect_y1=0;
32374 33160 draw_screen_clip_rect_y2=231;
32375 33160 }
32376 52360 }
32377
32378 52360 draw_screen();
32379
32380 //Run Triforce Script
32381 52360 advanceframe(true);
32382 52360 ++f;
32383
2/2
✓ Branch 0 taken 52260 times.
✓ Branch 1 taken 100 times.
104720 }
32384 while
32385 (
32386
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52360 times.
52360 (f < ( (itemsbuf[id2].misc4 > 0) ? itemsbuf[id2].misc4 : 408))
32387
4/6
✓ Branch 0 taken 7300 times.
✓ Branch 1 taken 45060 times.
✓ Branch 2 taken 7300 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7300 times.
52360 || (!(itemsbuf[id2].flags & item_flag15) /*&& !(itemsbuf[id2].flags & item_flag11)*/ && (midi_pos > 0 && !replay_is_active()))
32388
2/8
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 7300 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7300 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
14600 || (/*!(itemsbuf[id2].flags & item_flag15) &&*/ !(itemsbuf[id2].flags & item_flag11) && (zcmusic!=NULL) && (zcmusic->position<800 && !replay_is_active())
32389 // Music is played at the same speed when fps is uncapped, so in replay mode we need to ignore the music position and instead
32390 // just count frames. 480 is the number of frames it takes for the triforce song in classic_1st.qst to finish playing, but the exact
32391 // value doesn't matter.
32392
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7300 times.
7300 || (replay_is_active() && f < 480) )
32393 ); // 800 may not be just right, but it works
32394
32395 100 action=none; FFCore.setHeroAction(none);
32396 100 holdclk=0;
32397 100 draw_screen_clip_rect_x1=0;
32398 100 draw_screen_clip_rect_x2=255;
32399 100 draw_screen_clip_rect_y1=0;
32400 100 draw_screen_clip_rect_y2=231;
32401 100 show_subscreen_items=true;
32402
32403 //Warp Hero out of item cellars, in 2.10 and earlier quests. -Z ( 16th January, 2019 )
32404 //Added a QR for this, to Other->2, as `Triforce in Cellar Warps Hero Out`. -Z 15th March, 2019
32405
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 1 times.
100 if((itemsbuf[id2].flags & item_flag1) && ( get_qr(qr_SIDEVIEWTRIFORCECELLAR) ? ( cur_screen < MAPSCRS192b136 ) : (cur_screen < MAPSCRSNORMAL) ) )
32406 {
32407 99 sdir=dir;
32408 99 dowarp(hero_scr, 1, 0); //side warp
32409 99 }
32410 else
32411 {
32412
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if ( !(itemsbuf[id2].flags & item_flag11) ) playLevelMusic();
32413 }
32414 100 }
32415
32416 29289 void red_shift()
32417 {
32418 29289 int32_t tnum=176;
32419
32420 // set up the new palette
32421
2/2
✓ Branch 0 taken 937248 times.
✓ Branch 1 taken 29289 times.
966537 for(int32_t i=CSET(2); i < CSET(4); i++)
32422 {
32423 937248 int32_t r = (i-CSET(2)) << 1;
32424 937248 RAMpal[i+tnum].r = _rgb_scale_6[r];
32425 937248 RAMpal[i+tnum].g = _rgb_scale_6[r >> 3];
32426 937248 RAMpal[i+tnum].b = _rgb_scale_6[r >> 4];
32427 937248 }
32428
32429 // color scale the game screen
32430
2/2
✓ Branch 0 taken 4922328 times.
✓ Branch 1 taken 29289 times.
4951617 for(int32_t y=0; y<viewport.visible_height(show_bottom_8px); y++)
32431 {
32432
2/2
✓ Branch 0 taken 1260115968 times.
✓ Branch 1 taken 4922328 times.
1265038296 for(int32_t x=0; x<framebuf->w; x++)
32433 {
32434 1260115968 int c = framebuf->line[y+original_playing_field_offset][x];
32435 1260115968 int r = RAMpal[c].r / 4;
32436 1260115968 int g = RAMpal[c].g / 4;
32437 1260115968 int b = RAMpal[c].b / 4;
32438
2/2
✓ Branch 0 taken 1174976904 times.
✓ Branch 1 taken 85139064 times.
1260115968 int v = zc_min(int32_t(r*0.4 + g*0.6 + b*0.4)>>1,31);
32439
2/2
✓ Branch 0 taken 1259249135 times.
✓ Branch 1 taken 866833 times.
1260115968 putpixel(framebuf, x, y + original_playing_field_offset, c ? (v + tnum+CSET(2)) : 0);
32440 1260115968 }
32441 4922328 }
32442
32443 29289 refreshpal = true;
32444 29289 }
32445
32446 75 void slide_in_color(int32_t color)
32447 {
32448
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 75 times.
450 for(int32_t i=1; i<16; i+=3)
32449 {
32450 375 RAMpal[CSET(2)+i+2] = RAMpal[CSET(2)+i+1];
32451 375 RAMpal[CSET(2)+i+1] = RAMpal[CSET(2)+i];
32452 375 RAMpal[CSET(2)+i] = NESpal(color);
32453 375 }
32454
32455 75 refreshpal=true;
32456 75 }
32457
32458
32459 282 void HeroClass::heroDeathAnimation()
32460 {
32461 282 int32_t f=0;
32462 282 int32_t deathclk=0,deathfrm=0;
32463
32464 282 action=none; FFCore.setHeroAction(dying); //mayhaps a new action of 'gameover'? -Z
32465
32466 282 kill_sfx(); //call before the onDeath script.
32467
32468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 282 times.
282 if(!debug_enabled)
32469 {
32470 282 Paused=false;
32471 282 }
32472
32473 282 BITMAP *subscrbmp = create_bitmap_ex(8, framebuf->w, framebuf->h);
32474 282 clear_bitmap(subscrbmp);
32475 //get rid off all sprites but Hero
32476 282 guys.clear();
32477 282 items.clear();
32478 282 Ewpns.clear();
32479 282 Lwpns.clear();
32480 282 chainlinks.clear();
32481 282 decorations.clear();
32482
32483 282 kill_subscr_items();
32484
32485 282 Playing = false;
32486
32487
1/2
✓ Branch 0 taken 282 times.
✗ Branch 1 not taken.
282 game->set_deaths(zc_min(game->get_deaths()+1,USHRT_MAX));
32488 282 dir=down;
32489 282 music_stop();
32490
32491 282 attackclk=hclk=superman=0;
32492 282 scriptcoldet = true;
32493
32494
2/2
✓ Branch 0 taken 9024 times.
✓ Branch 1 taken 282 times.
9306 for(int32_t i=0; i<32; i++) miscellaneous[i] = 0;
32495
32496
32497 282 playing_field_offset = original_playing_field_offset; // otherwise, red_shift() may go past the bottom of the screen
32498 282 quakeclk=wavy=0;
32499
32500 //in original Z1, Hero marker vanishes at death.
32501 //code in subscr.cpp, put_passive_subscr checks the following value.
32502 //color 255 is a GUI color, so quest makers shouldn't be using this value.
32503 //Also, subscreen is static after death in Z1.
32504 282 int32_t tmp_hero_dot = QMisc.colors.hero_dot;
32505 282 QMisc.colors.hero_dot = 255;
32506
32507 282 put_passive_subscr(subscrbmp, 0, 0, game->should_show_time(), sspUP);
32508 //Don't forget passive subscreen scripts!
32509
2/2
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 24 times.
282 if(get_qr(qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN))
32510 {
32511 24 script_drawing_commands.Clear(); //We only want draws from this script
32512
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(DMaps[cur_dmap].passive_sub_script != 0)
32513 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script, cur_dmap);
32514
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
24 if (FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) && DMaps[cur_dmap].passive_sub_script != 0 && FFCore.doscript(ScriptType::ScriptedPassiveSubscreen))
32515 {
32516 ZScriptVersion::RunScript(ScriptType::ScriptedPassiveSubscreen, DMaps[cur_dmap].passive_sub_script, cur_dmap);
32517 FFCore.waitdraw(ScriptType::ScriptedPassiveSubscreen) = false;
32518 }
32519 24 BITMAP* tmp = framebuf;
32520 24 framebuf = subscrbmp; //Hack; force draws to subscrbmp
32521 24 do_script_draws(framebuf, origin_scr, 0, playing_field_offset); //Draw the script draws
32522 24 framebuf = tmp;
32523 24 script_drawing_commands.Clear(); //Don't let these draws repeat during 'draw_screen()'
32524 24 }
32525 282 QMisc.colors.hero_dot = tmp_hero_dot;
32526 282 bool clearedit = false;
32527 282 do
32528 {
32529
2/2
✓ Branch 0 taken 71105 times.
✓ Branch 1 taken 25856 times.
96961 if(f<254)
32530 {
32531
2/2
✓ Branch 0 taken 61863 times.
✓ Branch 1 taken 9242 times.
71105 if(f<=32)
32532 {
32533 9242 hclk=(32-f);
32534 9242 }
32535
32536
4/4
✓ Branch 0 taken 53743 times.
✓ Branch 1 taken 17362 times.
✓ Branch 2 taken 32525 times.
✓ Branch 3 taken 21218 times.
71105 if(f>=62 && f<138)
32537 {
32538
5/5
✓ Branch 0 taken 16751 times.
✓ Branch 1 taken 1117 times.
✓ Branch 2 taken 1117 times.
✓ Branch 3 taken 1117 times.
✓ Branch 4 taken 1116 times.
21218 switch((f-62)%20)
32539 {
32540 case 0:
32541 1117 dir=right;
32542 1117 break;
32543
32544 case 5:
32545 1117 dir=up;
32546 1117 break;
32547
32548 case 10:
32549 1117 dir=left;
32550 1117 break;
32551
32552 case 15:
32553 1116 dir=down;
32554 1116 break;
32555 }
32556
32557 21218 herostep();
32558 21218 }
32559
32560
4/4
✓ Branch 0 taken 16957 times.
✓ Branch 1 taken 54148 times.
✓ Branch 2 taken 12766 times.
✓ Branch 3 taken 4191 times.
71105 if(f>=194 && f<208)
32561 {
32562
2/2
✓ Branch 0 taken 3913 times.
✓ Branch 1 taken 278 times.
4191 if(f==194)
32563 {
32564 278 action=dying;
32565 278 FFCore.setHeroAction(dying);
32566 278 }
32567
32568 4191 extend = 0;
32569 4191 cs = wpnsbuf[spr_death].csets&15;
32570 4191 tile = wpnsbuf[spr_death].tile;
32571
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 607 times.
4191 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
32572 {
32573 607 tile += deathfrm;
32574 607 f = 206;
32575
2/2
✓ Branch 0 taken 519 times.
✓ Branch 1 taken 88 times.
607 if(++deathclk >= wpnsbuf[spr_death].speed)
32576 {
32577 88 deathclk=0;
32578
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 22 times.
88 if(++deathfrm >= wpnsbuf[spr_death].frames)
32579 {
32580 22 f = 208;
32581 22 deathfrm = 0;
32582 22 }
32583 88 }
32584 607 }
32585
2/2
✓ Branch 0 taken 2702 times.
✓ Branch 1 taken 882 times.
3584 else if(BSZ)
32586 {
32587 2702 tile += (f-194)/3;
32588 2702 }
32589
2/2
✓ Branch 0 taken 630 times.
✓ Branch 1 taken 252 times.
882 else if(f>=204)
32590 {
32591 252 ++tile;
32592 252 }
32593 4191 }
32594
32595
2/2
✓ Branch 0 taken 70827 times.
✓ Branch 1 taken 278 times.
71105 if(f==208)
32596 {
32597
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 274 times.
278 if ( dontdraw < 2 ) { dontdraw = 1; }
32598 278 }
32599
2/2
✓ Branch 0 taken 67295 times.
✓ Branch 1 taken 3810 times.
71105 if(get_qr(qr_FADE))
32600 {
32601
2/2
✓ Branch 0 taken 44926 times.
✓ Branch 1 taken 22369 times.
67295 if(f < 170)
32602 {
32603
2/2
✓ Branch 0 taken 29024 times.
✓ Branch 1 taken 15902 times.
44926 if(f<60)
32604 {
32605 15902 draw_screen();
32606 //reuse our static subscreen
32607 15902 set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
32608 15902 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32609 15902 }
32610
32611
2/2
✓ Branch 0 taken 44661 times.
✓ Branch 1 taken 265 times.
44926 if(f==60)
32612 {
32613 265 red_shift();
32614 265 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
32615 265 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
32616 265 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
32617
32618
2/2
✓ Branch 0 taken 67840 times.
✓ Branch 1 taken 265 times.
68105 for(int32_t q=0; q<PAL_SIZE; q++)
32619 {
32620 67840 trans_table2.data[0][q] = q;
32621 67840 trans_table2.data[q][q] = q;
32622 67840 }
32623 265 }
32624
32625
3/4
✓ Branch 0 taken 29024 times.
✓ Branch 1 taken 15902 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 29024 times.
44926 if(f>=60 && f<=169)
32626 {
32627 29024 draw_screen();
32628 //reuse our static subscreen
32629 29024 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32630 29024 red_shift();
32631
32632 29024 }
32633
32634
3/4
✓ Branch 0 taken 8153 times.
✓ Branch 1 taken 36773 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8153 times.
44926 if(f>=139 && f<=169)//fade from red to black
32635 {
32636 8153 fade_interpolate(RAMpal,black_palette,RAMpal, (f-138)<<1, 224, 255);
32637 8153 create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
32638 8153 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
32639 8153 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
32640
32641
2/2
✓ Branch 0 taken 2087168 times.
✓ Branch 1 taken 8153 times.
2095321 for(int32_t q=0; q<PAL_SIZE; q++)
32642 {
32643 2087168 trans_table2.data[0][q] = q;
32644 2087168 trans_table2.data[q][q] = q;
32645 2087168 }
32646
32647 8153 refreshpal=true;
32648 8153 }
32649 44926 }
32650 else //f>=170
32651 {
32652
2/2
✓ Branch 0 taken 22106 times.
✓ Branch 1 taken 263 times.
22369 if(f==170)//make Hero grayish
32653 {
32654 263 fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
32655
32656
2/2
✓ Branch 0 taken 4208 times.
✓ Branch 1 taken 263 times.
4471 for(int32_t i=CSET(6); i < CSET(7); i++)
32657 {
32658 4208 int32_t g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
32659 4208 RAMpal[i] = _RGB(g,g,g);
32660 4208 }
32661
32662 263 refreshpal = true;
32663 263 }
32664
32665 //draw only hero. otherwise black layers might cover him.
32666 22369 rectfill(framebuf,0,original_playing_field_offset,framebuf->w,framebuf->h,0);
32667 22369 draw(framebuf);
32668 22369 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32669 }
32670 67295 }
32671 else //!qr_FADE
32672 {
32673 7620 for_every_base_screen_in_region([&](mapscr* scr, unsigned int region_scr_x, unsigned int region_scr_y) {
32674
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==58)
32675 {
32676
2/2
✓ Branch 0 taken 1440 times.
✓ Branch 1 taken 15 times.
1455 for(int32_t i = 0; i < 96; i++)
32677 1440 scr->cset[i] = 3;
32678
32679
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=1; j<=6; j++)
32680
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(scr->layermap[j-1]>0)
32681 {
32682 2 mapscr* lyr_scr = get_scr_layer(scr->screen, j);
32683
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 2 times.
194 for(int32_t i=0; i<96; i++)
32684 192 lyr_scr->cset[i] = 3;
32685 2 }
32686 15 }
32687
32688
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==59)
32689 {
32690
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 15 times.
1215 for(int32_t i = 96; i < 176; i++)
32691 1200 scr->cset[i] = 3;
32692
32693
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=1; j<=6; j++)
32694
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(scr->layermap[j-1]>0)
32695 {
32696 2 mapscr* lyr_scr = get_scr_layer(scr->screen, j);
32697
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 2 times.
162 for(int32_t i=96; i<176; i++)
32698 160 lyr_scr->cset[i] = 3;
32699 2 }
32700 15 }
32701
32702
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==60)
32703 {
32704
2/2
✓ Branch 0 taken 2640 times.
✓ Branch 1 taken 15 times.
2655 for(int32_t i=0; i<176; i++)
32705 {
32706 2640 scr->cset[i] = 2;
32707 2640 }
32708
32709
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 15 times.
105 for(int32_t j=1; j<=6; j++)
32710
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 2 times.
92 if(scr->layermap[j-1]>0)
32711 {
32712 2 mapscr* lyr_scr = get_scr_layer(scr->screen, j);
32713
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 2 times.
354 for(int32_t i=0; i<176; i++)
32714 352 lyr_scr->cset[i] = 2;
32715 2 }
32716 15 }
32717 3810 });
32718
32719
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==60)
32720 {
32721
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 15 times.
90 for(int32_t i=1; i<16; i+=3)
32722 {
32723 75 RAMpal[CSET(2)+i] = NESpal(0x17);
32724 75 RAMpal[CSET(2)+i+1] = NESpal(0x16);
32725 75 RAMpal[CSET(2)+i+2] = NESpal(0x26);
32726 75 }
32727
32728 15 refreshpal=true;
32729 15 }
32730
32731
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==139)
32732 15 slide_in_color(0x06);
32733
32734
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==149)
32735 15 slide_in_color(0x07);
32736
32737
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==159)
32738 15 slide_in_color(0x0F);
32739
32740
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==169)
32741 {
32742 15 slide_in_color(0x0F);
32743 15 slide_in_color(0x0F);
32744 15 }
32745
32746
2/2
✓ Branch 0 taken 3795 times.
✓ Branch 1 taken 15 times.
3810 if(f==170)
32747 {
32748
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 15 times.
90 for(int32_t i=1; i<16; i+=3)
32749 {
32750 75 RAMpal[CSET(6)+i] = NESpal(0x10);
32751 75 RAMpal[CSET(6)+i+1] = NESpal(0x30);
32752 75 RAMpal[CSET(6)+i+2] = NESpal(0x00);
32753 75 refreshpal = true;
32754 75 }
32755 15 }
32756
32757
2/2
✓ Branch 0 taken 2535 times.
✓ Branch 1 taken 1275 times.
3810 if(f < 169)
32758 {
32759 2535 draw_screen();
32760 //reuse our static subscreen
32761 2535 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32762 2535 }
32763 else
32764 {
32765 //draw only hero. otherwise black layers might cover him.
32766 1275 rectfill(framebuf,0,playing_field_offset,framebuf->w,framebuf->h,0);
32767 1275 draw(framebuf);
32768 1275 blit(subscrbmp,framebuf,0,0,0,0,256,original_playing_field_offset);
32769 }
32770 }
32771 71105 }
32772
32773
2/2
✓ Branch 0 taken 25073 times.
✓ Branch 1 taken 783 times.
25856 else if(f<350)//draw 'GAME OVER' text
32774 {
32775
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 25071 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
25073 if(get_qr(qr_INSTANT_RESPAWN) && !get_qr(qr_INSTANT_CONTINUE))
32776 {
32777 2 Quit = qRELOAD;
32778 2 skipcont = 1;
32779 2 clear_bitmap(framebuf);
32780 2 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
32781 2 }
32782
3/4
✓ Branch 0 taken 25071 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25056 times.
✓ Branch 3 taken 15 times.
25071 else if(!get_qr(qr_INSTANT_RESPAWN) && get_qr(qr_INSTANT_CONTINUE))
32783 {
32784 15 Quit = qCONT;
32785 15 skipcont = 1;
32786 15 clear_bitmap(framebuf);
32787 15 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
32788 15 }
32789 else
32790 {
32791 25056 clear_info_bmp();
32792 25056 clear_to_color(framebuf,SaveScreenSettings[SAVESC_BACKGROUND]);
32793 25056 blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
32794 25056 textout_ex(framebuf,get_zc_font(font_zfont),"GAME OVER",96,playing_field_offset+80,SaveScreenSettings[SAVESC_TEXT],-1);
32795 }
32796 25073 }
32797 else
32798 {
32799 783 clear_bitmap(framebuf);
32800 }
32801
32802 //SFX... put them all here
32803
4/4
✓ Branch 0 taken 96143 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 256 times.
96961 switch(f)
32804 {
32805 case 0:
32806 282 sfx(getHurtSFX(),pan(x));
32807 282 break;
32808 //Death sound.
32809 case 60:
32810 280 sfx(WAV_SPIRAL);
32811 280 break;
32812 //Message sound.
32813 case 194:
32814 256 sfx(WAV_MSG);
32815 256 break;
32816 }
32817 //adv:
32818 96961 clear_darkroom_bitmaps();
32819 96961 advanceframe(true);
32820 96961 ++f;
32821
2/2
✓ Branch 0 taken 96679 times.
✓ Branch 1 taken 282 times.
193922 }
32822
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 96700 times.
96961 while(f<353 && !Quit);
32823
32824 282 destroy_bitmap(subscrbmp);
32825 282 action=none; FFCore.setHeroAction(none);
32826
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 278 times.
282 if ( dontdraw < 2 ) { dontdraw=0; }
32827 282 }
32828
32829 17 void HeroClass::ganon_intro()
32830 {
32831 17 mapscr* scr = hero_scr;
32832 17 int screen = scr->screen;
32833 77 auto [offx, offy] = translate_screen_coordinates_to_world(screen);
32834
32835 /*
32836 ************************
32837 * GANON INTRO SEQUENCE *
32838 ************************
32839 -25 DOT updates
32840 -24 HERO in
32841 0 TRIFORCE overhead - code begins at this point (f == 0)
32842 47 GANON in
32843 58 LIGHT step
32844 68 LIGHT step
32845 78 LIGHT step
32846 255 TRIFORCE out
32847 256 TRIFORCE in
32848 270 TRIFORCE out
32849 271 GANON out, HERO face up
32850 */
32851 17 loaded_guys=true;
32852 51 loaditem(scr, offx, offy);
32853
32854
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 13 times.
17 if(game->lvlitems[dlevel]&liBOSS)
32855 {
32856 4 return;
32857 }
32858
32859 13 dir=down;
32860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if ( !isSideViewHero() )
32861 {
32862 13 fall = 0; //Fix midair glitch on holding triforce. -Z
32863 13 fakefall = 0;
32864 13 z = 0;
32865 13 fakez = 0;
32866 13 }
32867 13 action=landhold2; FFCore.setHeroAction(landhold2);
32868 13 holditem=getItemID(itemsbuf,itype_triforcepiece, 1);
32869 //not good, as this only returns the highest level that Hero possesses. -DD
32870 //getHighestLevelOfFamily(game, itemsbuf, itype_triforcepiece, false));
32871
32872
4/4
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3133 times.
✓ Branch 2 taken 3133 times.
✓ Branch 3 taken 13 times.
3146 for(int32_t f=0; f<271 && !Quit; f++)
32873 {
32874
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==47)
32875 {
32876 13 music_stop();
32877 13 stop_sfx(WAV_ROAR);
32878 13 sfx(WAV_GASP);
32879 13 sfx(WAV_GANON);
32880 13 int32_t Id=0;
32881
32882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1027 times.
1027 for(int32_t i=0; i<eMAXGUYS; i++)
32883 {
32884
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 13 times.
1027 if(guysbuf[i].flags&guy_ganon)
32885 {
32886 13 Id=i;
32887 13 break;
32888 }
32889 1014 }
32890
32891
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 if(current_item(itype_ring))
32892 {
32893 30 addenemy(screen,offx+160,offy+96,Id,0);
32894 10 }
32895 else
32896 {
32897 9 addenemy(screen,offx+80,offy+32,Id,0);
32898 }
32899 13 }
32900
32901
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==48)
32902 {
32903 13 lighting(true,true); // Hmm. -L
32904 13 f += 30;
32905 13 }
32906
32907 //NES Z1, the triforce vanishes for one frame in two cases
32908 //while still showing Hero's two-handed overhead sprite.
32909 //This should be a Quest Rule for NES Accuracy. -Z
32910
4/4
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 3107 times.
3133 if(f==255 || f==270)
32911 {
32912 26 holditem=-1;
32913 26 }
32914
32915
2/2
✓ Branch 0 taken 3120 times.
✓ Branch 1 taken 13 times.
3133 if(f==256)
32916 {
32917 13 holditem=getItemID(itemsbuf,itype_triforcepiece,1);
32918 13 }
32919
32920 3133 draw_screen();
32921 3133 advanceframe(true);
32922
32923
1/2
✓ Branch 0 taken 3133 times.
✗ Branch 1 not taken.
3133 if(rSbtn())
32924 {
32925 conveyclk=3;
32926 int32_t tmp_subscr_clk = frame;
32927 dosubscr();
32928 newscr_clk += frame - tmp_subscr_clk;
32929 }
32930
32931 3133 }
32932
32933 13 action=none; FFCore.setHeroAction(none);
32934 13 dir=up;
32935
32936
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11 times.
13 if((!getmapflag(screen, mSPECIALITEM) || (scr->flags9&fBELOWRETURN)) && (tunes[MAXMIDIS-1].data))
32937 2 jukebox(MAXMIDIS-1);
32938 else
32939 11 playLevelMusic();
32940
32941 13 currcset=DMaps[cur_dmap].color;
32942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (get_qr(qr_GANONINTRO) )
32943 {
32944 13 dointro();
32945 //Yes, I checked. This is literally in 2.10 (minus this if statement of course).
32946 //I have no clue why it's here; Literally the only difference between dointro in 2.10 and dointro in this version is an 'else' that sets introclk and intropos to 74.
32947 //I have no idea what was going through the original devs heads and I'm extremely worried I'm missing something, cause at first glance this looks like
32948 //a hack solution to an underlying bug, but no! There's just a fucking dointro() call in older versions and I don't know *why*. -Deedee
32949 13 }
32950
32951 13 cont_sfx(WAV_ROAR);
32952 17 }
32953
32954 10 void HeroClass::win_game()
32955 {
32956
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 replay_step_comment("win_game");
32957 10 Playing=Paused=false;
32958 10 action=won; FFCore.setHeroAction(won);
32959 10 Quit=qWON;
32960 10 hclk=0;
32961 10 x = 136;
32962
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 y = (isdungeon() && cur_screen<128) ? 75 : 73;
32963 10 z = fakez = fall = fakefall = spins = 0;
32964 10 dir=left;
32965 10 }
32966
32967 40065 void HeroClass::reset_swordcharge()
32968 {
32969 40065 charging=spins=tapping=0;
32970 40065 }
32971
32972 142610 void HeroClass::reset_hookshot()
32973 {
32974
10/12
✓ Branch 0 taken 91834 times.
✓ Branch 1 taken 50776 times.
✓ Branch 2 taken 91820 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 91718 times.
✓ Branch 5 taken 102 times.
✓ Branch 6 taken 91711 times.
✓ Branch 7 taken 7 times.
✓ Branch 8 taken 91711 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 91711 times.
142610 if(action!=walking && action!=rafting && action!=landhold1 && action!=landhold2 && action!=sidewaterhold1 && action!=sidewaterhold2)
32975 {
32976 91711 action=none; FFCore.setHeroAction(none);
32977 91711 }
32978
32979 142610 hookshot_frozen=false;
32980 142610 hookshot_used=false;
32981 142610 pull_hero=false;
32982 142610 hs_fix=false;
32983 142610 switchhookclk = switchhookmaxtime = switchhookstyle = switchhookarg = 0;
32984 142610 switch_hooked = false;
32985
2/2
✓ Branch 0 taken 142605 times.
✓ Branch 1 taken 5 times.
142610 if(switching_object)
32986 5 switching_object->switch_hooked = false;
32987 142610 switching_object = NULL;
32988 142610 hooked_comborpos = rpos_t::None;
32989 142610 switchhook_cost_item = -1;
32990 142610 hooked_layerbits = 0;
32991
2/2
✓ Branch 0 taken 998270 times.
✓ Branch 1 taken 142610 times.
1140880 for(auto q = 0; q < 7; ++q)
32992 998270 hooked_undercombos[q] = -1;
32993 142610 Lwpns.del(Lwpns.idFirst(wHSHandle));
32994 142610 Lwpns.del(Lwpns.idFirst(wHookshot));
32995 142610 chainlinks.clear();
32996
2/2
✓ Branch 0 taken 35856 times.
✓ Branch 1 taken 106754 times.
142610 int32_t index=directWpn>-1 ? directWpn : current_item_id(hs_switcher ? itype_switchhook : itype_hookshot);
32997 142610 hs_switcher = false;
32998
32999
2/2
✓ Branch 0 taken 96530 times.
✓ Branch 1 taken 46080 times.
142610 if(index>=0)
33000 {
33001 46080 stop_sfx(itemsbuf[index].usesound);
33002 46080 }
33003
33004 142610 hs_xdist=0;
33005 142610 hs_ydist=0;
33006 142610 }
33007
33008
33009 17256590 bool HeroClass::can_deploy_ladder()
33010 {
33011
2/2
✓ Branch 0 taken 7099759 times.
✓ Branch 1 taken 10156831 times.
30496304 bool ladderallowed = ((!get_qr(qr_LADDERANYWHERE) && (hero_scr->flags&fLADDER)) || isdungeon()
33012
4/4
✓ Branch 0 taken 3924797 times.
✓ Branch 1 taken 13239714 times.
✓ Branch 2 taken 4778804 times.
✓ Branch 3 taken 8460910 times.
10156831 || (get_qr(qr_LADDERANYWHERE) && !(hero_scr->flags&fLADDER)));
33013
11/12
✓ Branch 0 taken 6746780 times.
✓ Branch 1 taken 17517490 times.
✓ Branch 2 taken 3086745 times.
✓ Branch 3 taken 3660035 times.
✓ Branch 4 taken 3086449 times.
✓ Branch 5 taken 296 times.
✓ Branch 6 taken 3085744 times.
✓ Branch 7 taken 705 times.
✓ Branch 8 taken 3085744 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3085626 times.
✓ Branch 11 taken 118 times.
27349896 return (current_item_id(itype_ladder)>-1 && ladderallowed && !ilswim && z==0 && fakez==0 && !hoverclk &&
33014
2/2
✓ Branch 0 taken 3064815 times.
✓ Branch 1 taken 20811 times.
3085626 (!isSideViewHero() || on_sideview_solid_oldpos(this)));
33015 }
33016
33017 9611684 void HeroClass::reset_ladder()
33018 {
33019
3/4
✓ Branch 0 taken 9609013 times.
✓ Branch 1 taken 2671 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9609013 times.
9611684 if (ladderx || laddery)
33020 {
33021 2671 ladderx = laddery = 0;
33022
33023
1/2
✓ Branch 0 taken 2671 times.
✗ Branch 1 not taken.
2671 if (is_autowalking())
33024 {
33025 if (check_pitslide() != -1)
33026 try_hover();
33027 }
33028 2671 }
33029 9611684 }
33030
33031 bool is_conveyor(int32_t type);
33032 int32_t get_conveyor(int32_t x, int32_t y);
33033
33034 14328344 void HeroClass::check_conveyor()
33035 {
33036 14328344 ++newconveyorclk;
33037
33038
2/2
✓ Branch 0 taken 14324968 times.
✓ Branch 1 taken 3376 times.
14328344 if (is_conveyor_stunned > 0)
33039 3376 --is_conveyor_stunned;
33040
2/2
✓ Branch 0 taken 14324664 times.
✓ Branch 1 taken 3680 times.
14328344 if (is_on_conveyor > 0)
33041 {
33042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3680 times.
3680 if(!--is_on_conveyor)
33043 3680 conv_forcedir = -1;
33044 3680 }
33045
33046
15/18
✓ Branch 0 taken 11194 times.
✓ Branch 1 taken 14317150 times.
✓ Branch 2 taken 14303877 times.
✓ Branch 3 taken 13273 times.
✓ Branch 4 taken 14303877 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14297765 times.
✓ Branch 7 taken 6112 times.
✓ Branch 8 taken 14297765 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14297509 times.
✓ Branch 11 taken 256 times.
✓ Branch 12 taken 14290214 times.
✓ Branch 13 taken 7295 times.
✓ Branch 14 taken 14273031 times.
✓ Branch 15 taken 17183 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 14273031 times.
14328344 if((!get_qr(qr_BROKEN_CONVEYORS) && action==rafting) || action==casting||action==sideswimcasting||action==drowning || action==sidedrowning||action==lavadrowning||inlikelike||pull_hero||is_autowalking())
33047 {
33048 55313 is_conveyor_stunned = 0;
33049 55313 return;
33050 }
33051
33052 14273031 WalkflagInfo info;
33053 int32_t xoff,yoff;
33054 14273031 zfix deltax(0), deltay(0);
33055 14273031 int32_t cmbid = get_conveyor(x+7,y+(bigHitbox?8:12));
33056
2/2
✓ Branch 0 taken 19479 times.
✓ Branch 1 taken 14253552 times.
14273031 if(cmbid < 0)
33057 {
33058
2/2
✓ Branch 0 taken 9524010 times.
✓ Branch 1 taken 4729542 times.
14253552 if (conveyclk <= 0)
33059 {
33060
2/2
✓ Branch 0 taken 4728606 times.
✓ Branch 1 taken 936 times.
4729542 if(is_on_conveyor < 0)
33061 {
33062 936 is_on_conveyor = 0;
33063 936 conv_forcedir = -1;
33064 936 is_conveyor_stunned = 0;
33065 936 }
33066 4729542 }
33067 14253552 return;
33068 }
33069 19479 newcombo const* cmb = &combobuf[cmbid];
33070 19479 rpos_t rpos = COMBOPOS_REGION(x+7,y+(bigHitbox?8:12));
33071 19479 bool custom_spd = (cmb->usrflags&cflag2);
33072
6/6
✓ Branch 0 taken 19324 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 155 times.
✓ Branch 3 taken 19324 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 17 times.
19479 if((z>0||fakez>0) && !((hero_scr->flags2&fAIRCOMBOS)||(cmb->usrflags&cflag7)))
33073 {
33074 17 is_on_conveyor = 0;
33075 17 conv_forcedir = -1;
33076 17 is_conveyor_stunned = 0;
33077 17 return;
33078 }
33079
3/4
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 3680 times.
✓ Branch 2 taken 15782 times.
✗ Branch 3 not taken.
19462 if(custom_spd || conveyclk<=0) //!DIMITODO: let player be on multiple conveyors at once
33080 {
33081 19462 int32_t ctype=cmb->type;
33082
4/4
✓ Branch 0 taken 3680 times.
✓ Branch 1 taken 15782 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 3430 times.
19462 auto rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
33083
3/4
✓ Branch 0 taken 3680 times.
✓ Branch 1 taken 15782 times.
✓ Branch 2 taken 3680 times.
✗ Branch 3 not taken.
19462 if(custom_spd && (newconveyorclk % rate)) return;
33084
3/4
✓ Branch 0 taken 3271 times.
✓ Branch 1 taken 16191 times.
✓ Branch 2 taken 3271 times.
✗ Branch 3 not taken.
19462 if((cmb->usrflags&cflag5) && HasHeavyBoots())
33085 return;
33086 19462 is_on_conveyor = 0;
33087 19462 conv_forcedir = -1;
33088 19462 is_conveyor_stunned = 0;
33089
33090 19462 deltax=combo_class_buf[ctype].conveyor_x_speed;
33091 19462 deltay=combo_class_buf[ctype].conveyor_y_speed;
33092
33093
3/4
✓ Branch 0 taken 19462 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15782 times.
✓ Branch 3 taken 3680 times.
19462 if (is_conveyor(ctype) && custom_spd)
33094 {
33095 3680 deltax = zslongToFix(cmb->attributes[0]);
33096 3680 deltay = zslongToFix(cmb->attributes[1]);
33097 3680 }
33098
33099
3/8
✓ Branch 0 taken 8832 times.
✓ Branch 1 taken 10630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8832 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
19462 if((deltax==0&&deltay==0)&&(isSideViewHero() && on_sideview_solid_oldpos(this)))
33100 {
33101 cmbid = MAPCOMBO(x+8,y+16);
33102 cmb = &combobuf[cmbid];
33103 custom_spd = cmb->usrflags&cflag2;
33104 ctype=(cmb->type);
33105 rate = custom_spd ? zc_max(cmb->attribytes[0], 1) : 3;
33106 deltax=combo_class_buf[ctype].conveyor_x_speed;
33107 deltay=combo_class_buf[ctype].conveyor_y_speed;
33108 if ((deltax != 0 || deltay != 0) && custom_spd)
33109 {
33110 deltax = zslongToFix(cmb->attributes[0]);
33111 deltay = zslongToFix(cmb->attributes[1]);
33112 }
33113 }
33114
33115
3/4
✓ Branch 0 taken 8832 times.
✓ Branch 1 taken 10630 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8832 times.
19462 if(deltax!=0||deltay!=0)
33116 {
33117
2/2
✓ Branch 0 taken 3680 times.
✓ Branch 1 taken 15782 times.
19462 is_on_conveyor = custom_spd ? rate : -1;
33118 19462 }
33119 else return;
33120
33121
2/2
✓ Branch 0 taken 19303 times.
✓ Branch 1 taken 159 times.
19462 bool forcewalk = (cmb->usrflags&cflag6) && get_qr(qr_NEW_HERO_MOVEMENT2);
33122
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 19303 times.
19462 if(forcewalk)
33123 {
33124 159 is_conveyor_stunned = rate;
33125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159 times.
159 if(cmb->usrflags&cflag3)
33126 {
33127
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 50 times.
159 if(abs(deltax) > abs(deltay))
33128 109 conv_forcedir = dir = (deltax > 0) ? right : left;
33129 50 else conv_forcedir = dir = (deltay > 0) ? down : up;
33130 159 }
33131 159 convey_forcex = deltax;
33132 159 convey_forcey = deltay;
33133 159 }
33134 else
33135 {
33136 19303 bool movedx = false, movedy = false;
33137
2/2
✓ Branch 0 taken 15782 times.
✓ Branch 1 taken 3521 times.
19303 if(cmb->usrflags&cflag4) //Smart corners
33138 {
33139
2/2
✓ Branch 0 taken 1149 times.
✓ Branch 1 taken 2372 times.
3521 if(deltay<0)
33140 {
33141 1149 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
33142 1149 execute(info);
33143
33144
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 1098 times.
1149 if(!info.isUnwalkable())
33145 {
33146 1098 movedy = true;
33147 1098 zfix step(0);
33148
33149
7/12
✓ Branch 0 taken 1017 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 924 times.
✓ Branch 4 taken 30 times.
✓ Branch 5 taken 144 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 30 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1098 if ((getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) && dir != left && dir != right && !(diagonalMovement || NO_GRIDLOCK))
33150 {
33151 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
33152 {
33153 yoff=int32_t(y-step)&7;
33154
33155 if(!yoff) break;
33156
33157 step++;
33158 }
33159 }
33160 else
33161 {
33162 1098 step=abs(deltay);
33163 }
33164
33165 1098 y=y-step;
33166 1098 hs_starty-=step.getInt();
33167
33168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1098 times.
1098 for(int32_t j=0; j<chainlinks.Count(); j++)
33169 {
33170 chainlinks.spr(j)->y-=step;
33171 }
33172
33173
1/2
✓ Branch 0 taken 1098 times.
✗ Branch 1 not taken.
1098 if(Lwpns.idFirst(wHookshot)>-1)
33174 {
33175 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
33176 }
33177
33178
1/2
✓ Branch 0 taken 1098 times.
✗ Branch 1 not taken.
1098 if(Lwpns.idFirst(wHSHandle)>-1)
33179 {
33180 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
33181 }
33182 1098 }
33183 1149 }
33184
2/2
✓ Branch 0 taken 1945 times.
✓ Branch 1 taken 427 times.
2372 else if(deltay>0)
33185 {
33186 427 info = walkflag(x,y+15+2,2,down);
33187 427 execute(info);
33188
33189
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 422 times.
427 if(!info.isUnwalkable())
33190 {
33191 422 movedy = true;
33192 422 zfix step(0);
33193
33194
7/12
✓ Branch 0 taken 311 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 311 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 102 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
422 if ((getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) && dir != left && dir != right && !(diagonalMovement || NO_GRIDLOCK))
33195 {
33196 while(step<abs(deltay))
33197 {
33198 yoff=int32_t(y+step)&7;
33199
33200 if(!yoff) break;
33201
33202 step++;
33203 }
33204 }
33205 else
33206 {
33207 422 step=abs(deltay);
33208 }
33209
33210 422 y=y+step;
33211 422 hs_starty+=step.getInt();
33212
33213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 422 times.
422 for(int32_t j=0; j<chainlinks.Count(); j++)
33214 {
33215 chainlinks.spr(j)->y+=step;
33216 }
33217
33218
1/2
✓ Branch 0 taken 422 times.
✗ Branch 1 not taken.
422 if(Lwpns.idFirst(wHookshot)>-1)
33219 {
33220 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
33221 }
33222
33223
1/2
✓ Branch 0 taken 422 times.
✗ Branch 1 not taken.
422 if(Lwpns.idFirst(wHSHandle)>-1)
33224 {
33225 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
33226 }
33227 422 }
33228 427 }
33229
33230
2/2
✓ Branch 0 taken 532 times.
✓ Branch 1 taken 2989 times.
3521 if(deltax<0)
33231 {
33232 532 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
33233 532 execute(info);
33234
33235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 if(!info.isUnwalkable())
33236 {
33237 532 movedx = true;
33238 532 zfix step(0);
33239
33240
7/12
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 522 times.
✓ Branch 4 taken 9 times.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 9 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
532 if ((getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) && dir != up && dir != down && !(diagonalMovement || NO_GRIDLOCK))
33241 {
33242 while(step<abs(deltax))
33243 {
33244 xoff=int32_t(x-step)&7;
33245
33246 if(!xoff) break;
33247
33248 step++;
33249 }
33250 }
33251 else
33252 {
33253 532 step=abs(deltax);
33254 }
33255
33256 532 x=x-step;
33257 532 hs_startx-=step.getInt();
33258
33259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 532 times.
532 for(int32_t j=0; j<chainlinks.Count(); j++)
33260 {
33261 chainlinks.spr(j)->x-=step;
33262 }
33263
33264
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(Lwpns.idFirst(wHookshot)>-1)
33265 {
33266 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
33267 }
33268
33269
1/2
✓ Branch 0 taken 532 times.
✗ Branch 1 not taken.
532 if(Lwpns.idFirst(wHSHandle)>-1)
33270 {
33271 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
33272 }
33273 532 }
33274 532 }
33275
2/2
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 1413 times.
2989 else if(deltax>0)
33276 {
33277 1413 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
33278 1413 execute(info);
33279
33280
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1399 times.
1413 if(!info.isUnwalkable())
33281 {
33282 1399 movedx = true;
33283 1399 zfix step(0);
33284
33285
7/12
✓ Branch 0 taken 1221 times.
✓ Branch 1 taken 178 times.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 1184 times.
✓ Branch 4 taken 168 times.
✓ Branch 5 taken 47 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 168 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
1399 if ((getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) && dir != up && dir != down && !(diagonalMovement || NO_GRIDLOCK))
33286 {
33287 while(step<abs(deltax))
33288 {
33289 xoff=int32_t(x+step)&7;
33290
33291 if(!xoff) break;
33292
33293 step++;
33294 }
33295 }
33296 else
33297 {
33298 1399 step=abs(deltax);
33299 }
33300
33301 1399 x=x+step;
33302 1399 hs_startx+=step.getInt();
33303
33304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1399 times.
1399 for(int32_t j=0; j<chainlinks.Count(); j++)
33305 {
33306 chainlinks.spr(j)->x+=step;
33307 }
33308
33309
1/2
✓ Branch 0 taken 1399 times.
✗ Branch 1 not taken.
1399 if(Lwpns.idFirst(wHookshot)>-1)
33310 {
33311 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
33312 }
33313
33314
1/2
✓ Branch 0 taken 1399 times.
✗ Branch 1 not taken.
1399 if(Lwpns.idFirst(wHSHandle)>-1)
33315 {
33316 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
33317 }
33318 1399 }
33319 1413 }
33320
5/6
✓ Branch 0 taken 1945 times.
✓ Branch 1 taken 1576 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 1931 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 14 times.
3521 if(deltax && !movedx && !deltay)
33321 {
33322 14 zfix oy = y;
33323 14 y = COMBOY_REGION(rpos);
33324 14 bool validpush = scr_canmove(deltax, 0, false, false);
33325
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
28 zfix ny = handle_movestate_zfix([&]()
33326 {
33327 14 movexy(deltax,0,false,false,true,true);
33328 14 return y;
33329 });
33330 14 y = oy;
33331
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14 if (validpush || ny != COMBOY_REGION(rpos))
33332 {
33333
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if (y <= ny-1)
33334 {
33335 14 setYfix(y+1);
33336 14 }
33337 else if (y >= ny+1)
33338 {
33339 setYfix(y-1);
33340 }
33341 else
33342 {
33343 setYfix(ny);
33344 }
33345 14 }
33346 14 }
33347
5/6
✓ Branch 0 taken 1576 times.
✓ Branch 1 taken 1945 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 1520 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
3521 if(deltay && !movedy && !deltax)
33348 {
33349 56 zfix ox = x;
33350 56 x = COMBOX_REGION(rpos);
33351 56 bool validpush = scr_canmove(0, deltay, false, false);
33352
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
112 zfix nx = handle_movestate_zfix([&]()
33353 {
33354 56 movexy(0,deltay,false,false,true,true);
33355 56 return x;
33356 });
33357 56 x = ox;
33358
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
56 if (validpush || nx != COMBOX_REGION(rpos))
33359 {
33360
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 3 times.
56 if (x <= nx-1)
33361 {
33362 53 setXfix(x+1);
33363 53 }
33364
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (x >= nx+1)
33365 {
33366 setXfix(x-1);
33367 }
33368 else
33369 {
33370 3 setXfix(nx);
33371 }
33372 56 }
33373 56 }
33374 3521 }
33375
2/2
✓ Branch 0 taken 1520 times.
✓ Branch 1 taken 17783 times.
19303 if(!movedy)
33376 {
33377
2/2
✓ Branch 0 taken 2764 times.
✓ Branch 1 taken 15019 times.
17783 if(deltay<0)
33378 {
33379 2764 info = walkflag(x,y+8-(bigHitbox*8)-2,2,up);
33380 2764 execute(info);
33381
33382
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 2517 times.
2764 if(!info.isUnwalkable())
33383 {
33384 2517 movedy = true;
33385 2517 zfix step(0);
33386
33387
10/12
✓ Branch 0 taken 1942 times.
✓ Branch 1 taken 575 times.
✓ Branch 2 taken 703 times.
✓ Branch 3 taken 1814 times.
✓ Branch 4 taken 218 times.
✓ Branch 5 taken 485 times.
✓ Branch 6 taken 195 times.
✓ Branch 7 taken 23 times.
✓ Branch 8 taken 195 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 195 times.
2517 if ((getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) && dir != left && dir != right && !(diagonalMovement || NO_GRIDLOCK))
33388 {
33389
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 373 times.
530 while(step<(abs(deltay)*(isSideViewHero()?2:1)))
33390 {
33391 373 yoff=int32_t(y-step)&7;
33392
33393
2/2
✓ Branch 0 taken 335 times.
✓ Branch 1 taken 38 times.
373 if(!yoff) break;
33394
33395 335 step++;
33396 }
33397 195 }
33398 else
33399 {
33400 2322 step=abs(deltay);
33401 }
33402
33403 2517 y=y-step;
33404 2517 hs_starty-=step.getInt();
33405
33406
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 2517 times.
2536 for(int32_t j=0; j<chainlinks.Count(); j++)
33407 {
33408 19 chainlinks.spr(j)->y-=step;
33409 19 }
33410
33411
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 19 times.
2517 if(Lwpns.idFirst(wHookshot)>-1)
33412 {
33413 19 Lwpns.spr(Lwpns.idFirst(wHookshot))->y-=step;
33414 19 }
33415
33416
2/2
✓ Branch 0 taken 2498 times.
✓ Branch 1 taken 19 times.
2517 if(Lwpns.idFirst(wHSHandle)>-1)
33417 {
33418 19 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y-=step;
33419 19 }
33420 2517 }
33421 247 else checkdamagecombos(x,y+8-(bigHitbox ? 8 : 0)-2);
33422 2764 }
33423
2/2
✓ Branch 0 taken 10521 times.
✓ Branch 1 taken 4498 times.
15019 else if(deltay>0)
33424 {
33425 4498 info = walkflag(x,y+15+2,2,down);
33426 4498 execute(info);
33427
33428
2/2
✓ Branch 0 taken 897 times.
✓ Branch 1 taken 3601 times.
4498 if(!info.isUnwalkable())
33429 {
33430 3601 movedy = true;
33431 3601 zfix step(0);
33432
33433
10/12
✓ Branch 0 taken 2879 times.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 956 times.
✓ Branch 3 taken 2645 times.
✓ Branch 4 taken 444 times.
✓ Branch 5 taken 512 times.
✓ Branch 6 taken 388 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 388 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 388 times.
3601 if ((getInput(btnRight, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnLeft, INPUT_DRUNK | INPUT_HERO_ACTION)) && dir != left && dir != right && !(diagonalMovement || NO_GRIDLOCK))
33434 {
33435
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 646 times.
881 while(step<abs(deltay))
33436 {
33437 646 yoff=int32_t(y+step)&7;
33438
33439
2/2
✓ Branch 0 taken 493 times.
✓ Branch 1 taken 153 times.
646 if(!yoff) break;
33440
33441 493 step++;
33442 }
33443 388 }
33444 else
33445 {
33446 3213 step=abs(deltay);
33447 }
33448
33449 3601 y=y+step;
33450 3601 hs_starty+=step.getInt();
33451
33452
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3601 times.
3614 for(int32_t j=0; j<chainlinks.Count(); j++)
33453 {
33454 13 chainlinks.spr(j)->y+=step;
33455 13 }
33456
33457
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 39 times.
3601 if(Lwpns.idFirst(wHookshot)>-1)
33458 {
33459 39 Lwpns.spr(Lwpns.idFirst(wHookshot))->y+=step;
33460 39 }
33461
33462
2/2
✓ Branch 0 taken 3562 times.
✓ Branch 1 taken 39 times.
3601 if(Lwpns.idFirst(wHSHandle)>-1)
33463 {
33464 39 Lwpns.spr(Lwpns.idFirst(wHSHandle))->y+=step;
33465 39 }
33466 3601 }
33467 897 else checkdamagecombos(x,y+15);
33468 4498 }
33469 17783 }
33470
2/2
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 17372 times.
19303 if(!movedx)
33471 {
33472
2/2
✓ Branch 0 taken 5381 times.
✓ Branch 1 taken 11991 times.
17372 if(deltax<0)
33473 {
33474 5381 info = walkflag(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0),1,left);
33475 5381 execute(info);
33476
33477
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 5104 times.
5381 if(!info.isUnwalkable())
33478 {
33479 5104 movedx = true;
33480 5104 zfix step(0);
33481
33482
10/12
✓ Branch 0 taken 4579 times.
✓ Branch 1 taken 525 times.
✓ Branch 2 taken 689 times.
✓ Branch 3 taken 4415 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 372 times.
✓ Branch 6 taken 244 times.
✓ Branch 7 taken 73 times.
✓ Branch 8 taken 244 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 244 times.
5104 if ((getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) && dir != up && dir != down && !(diagonalMovement || NO_GRIDLOCK))
33483 {
33484
2/2
✓ Branch 0 taken 179 times.
✓ Branch 1 taken 456 times.
635 while(step<abs(deltax))
33485 {
33486 456 xoff=int32_t(x-step)&7;
33487
33488
2/2
✓ Branch 0 taken 391 times.
✓ Branch 1 taken 65 times.
456 if(!xoff) break;
33489
33490 391 step++;
33491 }
33492 244 }
33493 else
33494 {
33495 4860 step=abs(deltax);
33496 }
33497
33498 5104 x=x-step;
33499 5104 hs_startx-=step.getInt();
33500
33501
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5104 times.
5146 for(int32_t j=0; j<chainlinks.Count(); j++)
33502 {
33503 42 chainlinks.spr(j)->x-=step;
33504 42 }
33505
33506
2/2
✓ Branch 0 taken 5053 times.
✓ Branch 1 taken 51 times.
5104 if(Lwpns.idFirst(wHookshot)>-1)
33507 {
33508 51 Lwpns.spr(Lwpns.idFirst(wHookshot))->x-=step;
33509 51 }
33510
33511
2/2
✓ Branch 0 taken 5053 times.
✓ Branch 1 taken 51 times.
5104 if(Lwpns.idFirst(wHSHandle)>-1)
33512 {
33513 51 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x-=step;
33514 51 }
33515 5104 }
33516 277 else checkdamagecombos(x-int32_t(lsteps[x.getInt()&7]),y+8-(bigHitbox ? 8 : 0));
33517 5381 }
33518
2/2
✓ Branch 0 taken 8782 times.
✓ Branch 1 taken 3209 times.
11991 else if(deltax>0)
33519 {
33520 3209 info = walkflag(x+15+2,y+8-(bigHitbox ? 8 : 0),1,right);
33521 3209 execute(info);
33522
33523
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 3127 times.
3209 if(!info.isUnwalkable())
33524 {
33525 3127 movedx = true;
33526 3127 zfix step(0);
33527
33528
10/12
✓ Branch 0 taken 2627 times.
✓ Branch 1 taken 500 times.
✓ Branch 2 taken 510 times.
✓ Branch 3 taken 2617 times.
✓ Branch 4 taken 309 times.
✓ Branch 5 taken 201 times.
✓ Branch 6 taken 203 times.
✓ Branch 7 taken 106 times.
✓ Branch 8 taken 203 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 203 times.
3127 if ((getInput(btnUp, INPUT_DRUNK | INPUT_HERO_ACTION) || getInput(btnDown, INPUT_DRUNK | INPUT_HERO_ACTION)) && dir != up && dir != down && !(diagonalMovement || NO_GRIDLOCK))
33529 {
33530
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 341 times.
460 while(step<abs(deltax))
33531 {
33532 341 xoff=int32_t(x+step)&7;
33533
33534
2/2
✓ Branch 0 taken 257 times.
✓ Branch 1 taken 84 times.
341 if(!xoff) break;
33535
33536 257 step++;
33537 }
33538 203 }
33539 else
33540 {
33541 2924 step=abs(deltax);
33542 }
33543
33544 3127 x=x+step;
33545 3127 hs_startx+=step.getInt();
33546
33547
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 3127 times.
3148 for(int32_t j=0; j<chainlinks.Count(); j++)
33548 {
33549 21 chainlinks.spr(j)->x+=step;
33550 21 }
33551
33552
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 23 times.
3127 if(Lwpns.idFirst(wHookshot)>-1)
33553 {
33554 23 Lwpns.spr(Lwpns.idFirst(wHookshot))->x+=step;
33555 23 }
33556
33557
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 23 times.
3127 if(Lwpns.idFirst(wHSHandle)>-1)
33558 {
33559 23 Lwpns.spr(Lwpns.idFirst(wHSHandle))->x+=step;
33560 23 }
33561 3127 }
33562 82 else checkdamagecombos(x+15+2,y+8-(bigHitbox ? 8 : 0));
33563 3209 }
33564 17372 }
33565
4/4
✓ Branch 0 taken 9141 times.
✓ Branch 1 taken 10162 times.
✓ Branch 2 taken 7638 times.
✓ Branch 3 taken 1503 times.
19303 if(movedx || movedy)
33566 {
33567
2/2
✓ Branch 0 taken 14583 times.
✓ Branch 1 taken 3217 times.
17800 if(cmb->usrflags&cflag1)
33568 3217 is_conveyor_stunned = rate;
33569
2/2
✓ Branch 0 taken 17550 times.
✓ Branch 1 taken 250 times.
17800 if(cmb->usrflags&cflag3)
33570 {
33571
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 74 times.
250 if(abs(deltax) > abs(deltay))
33572 176 conv_forcedir = dir = (deltax > 0) ? right : left;
33573 74 else conv_forcedir = dir = (deltay > 0) ? down : up;
33574 250 }
33575 17800 }
33576 }
33577 19462 }
33578 14307772 }
33579
33580 void HeroClass::setDivineProtectionShieldClk(int32_t newclk)
33581 {
33582 DivineProtectionShieldClk=newclk;
33583
33584 if(decorations.idCount(dDIVINEPROTECTIONSHIELD)==0)
33585 {
33586 // TODO(crash): check that .add succeeds.
33587 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
33588 decorations.spr(decorations.Count()-1)->misc=0;
33589 decorations.add(new dDivineProtectionShield(HeroX(), HeroY(), dDIVINEPROTECTIONSHIELD, 0));
33590 decorations.spr(decorations.Count()-1)->misc=1;
33591 }
33592 }
33593
33594 36017 int32_t HeroClass::getDivineProtectionShieldClk()
33595 {
33596 36017 return DivineProtectionShieldClk;
33597 }
33598
33599 21 int32_t HeroClass::getHoverClk()
33600 {
33601 21 return hoverclk;
33602 }
33603
33604 26317048 int32_t HeroClass::getHoldClk()
33605 {
33606 26317048 return holdclk;
33607 }
33608
33609 8411510 int32_t HeroClass::getLastLensID(){
33610 8411510 return last_lens_id;
33611 }
33612
33613 210 void HeroClass::setLastLensID(int32_t p_item){
33614 210 last_lens_id = p_item;
33615 210 }
33616
33617 106172484 bool HeroClass::getOnSideviewLadder()
33618 {
33619 106172484 return on_sideview_ladder;
33620 }
33621
33622 370 void HeroClass::setOnSideviewLadder(bool val)
33623 {
33624
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 9 times.
370 if(val)
33625 {
33626 9 fall = fakefall = hoverclk = jumping = 0;
33627 9 hoverflags = 0;
33628 9 inair = false;
33629 9 }
33630 370 on_sideview_ladder = val;
33631 370 }
33632
33633 4675037 bool HeroClass::canSideviewLadder(bool down)
33634 {
33635
2/2
✓ Branch 0 taken 4630796 times.
✓ Branch 1 taken 44241 times.
4675037 if(!isSideViewHero()) return false;
33636
2/2
✓ Branch 0 taken 26461 times.
✓ Branch 1 taken 17780 times.
44241 if(jumping < 0) return false;
33637
2/2
✓ Branch 0 taken 15182 times.
✓ Branch 1 taken 11279 times.
26461 if (down)
33638 {
33639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11279 times.
11279 if (check_new_slope(x, y + 0.0001_zf, 16, 16, old_x, old_y, true))
33640 {
33641 return false;
33642 }
33643 11279 }
33644
3/4
✓ Branch 0 taken 11279 times.
✓ Branch 1 taken 15182 times.
✓ Branch 2 taken 11279 times.
✗ Branch 3 not taken.
26461 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
33645 {
33646 bool onSolid = on_sideview_solid_oldpos(this,true);
33647 return ((isSVLadder(x+4,y+16) && (!isSVLadder(x+4,y)||onSolid)) || (isSVLadder(x+12,y+16) && (!isSVLadder(x+12,y)||onSolid)));
33648 }
33649 //Are you presently able to climb a sideview ladder?
33650 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
33651 //y+0 checks your top-half for large hitbox; y+8 for small
33652 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
33653 //y+16 check is for going down onto a ladder you are standing on.
33654
2/2
✓ Branch 0 taken 25839 times.
✓ Branch 1 taken 622 times.
52300 return (isSVLadder(x+4,y+(bigHitbox?0:8)) || isSVLadder(x+12,y+(bigHitbox?0:8)))
33655
3/4
✓ Branch 0 taken 25839 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25831 times.
✓ Branch 3 taken 8 times.
25839 || isSVLadder(x+4,y+15) || isSVLadder(x+12,y+15)
33656
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 25831 times.
✓ Branch 2 taken 14552 times.
✓ Branch 3 taken 11279 times.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 11278 times.
37110 || (down && (isSVLadder(x+4,y+16) || isSVLadder(x+12,y+16)));
33657 4675037 }
33658
33659 bool HeroClass::canSideviewLadderRemote(int32_t wx, int32_t wy, bool down)
33660 {
33661 if(!isSideViewHero()) return false;
33662 if(jumping < 0) return false;
33663 if(down && get_qr(qr_DOWN_DOESNT_GRAB_LADDERS))
33664 {
33665 bool onSolid = on_sideview_solid_oldpos(this,true);
33666 return ((isSVLadder(wx+4,wy+16) && (!isSVLadder(wx+4,wy)||onSolid)) || (isSVLadder(wx+12,wy+16) && (!isSVLadder(wx+12,wy)||onSolid)));
33667 }
33668 //Are you presently able to climb a sideview ladder?
33669 //x+4 / +12 are the offsets used for detecting a platform below you in sideview
33670 //y+0 checks your top-half for large hitbox; y+8 for small
33671 //y+15 checks if you are on one at all. This is necessary so you don't just fall off before reaching the top.
33672 //y+16 check is for going down onto a ladder you are standing on.
33673 return (isSVLadder(wx+4,wy+(bigHitbox?0:8)) || isSVLadder(wx+12,wy+(bigHitbox?0:8)))
33674 || isSVLadder(wx+4,wy+15) || isSVLadder(wx+12,wy+15)
33675 || (down && (isSVLadder(wx+4,wy+16) || isSVLadder(wx+12,wy+16)));
33676 }
33677
33678 10010375 void HeroClass::execute(HeroClass::WalkflagInfo info)
33679 {
33680 10010375 int32_t flags = info.getFlags();
33681
33682
2/2
✓ Branch 0 taken 1770 times.
✓ Branch 1 taken 10008605 times.
10010375 if(flags & WalkflagInfo::CLEARILSWIM)
33683 1770 ilswim =false;
33684
2/2
✓ Branch 0 taken 10005265 times.
✓ Branch 1 taken 3340 times.
10008605 else if(flags & WalkflagInfo::SETILSWIM)
33685 3340 ilswim = true;
33686
33687
1/2
✓ Branch 0 taken 10010375 times.
✗ Branch 1 not taken.
10010375 if(flags & WalkflagInfo::CLEARCHARGEATTACK)
33688 {
33689 charging = 0;
33690 attackclk = 0;
33691 }
33692
33693
1/2
✓ Branch 0 taken 10010375 times.
✗ Branch 1 not taken.
10010375 if(flags & WalkflagInfo::SETDIR)
33694 {
33695 dir = info.getDir();
33696 }
33697
33698
2/2
✓ Branch 0 taken 10009087 times.
✓ Branch 1 taken 1288 times.
10010375 if(flags & WalkflagInfo::SETHOPCLK)
33699 {
33700 1288 hopclk = info.getHopClk();
33701 1288 }
33702
33703
2/2
✓ Branch 0 taken 10008931 times.
✓ Branch 1 taken 1444 times.
10010375 if(flags & WalkflagInfo::SETHOPDIR)
33704 {
33705 1444 hopdir = info.getHopDir();
33706 1444 }
33707
33708 10010375 }
33709
33710 17803273 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator ||(HeroClass::WalkflagInfo other)
33711 {
33712 17803273 HeroClass::WalkflagInfo ret;
33713 17803273 ret.newhopclk = newhopclk;
33714 17803273 ret.newdir = newdir;
33715
2/2
✓ Branch 0 taken 14799327 times.
✓ Branch 1 taken 3003946 times.
17803273 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
33716
33717 17803273 int32_t flags1 = (flags & ~UNWALKABLE) & (other.flags & ~UNWALKABLE);
33718 17803273 int32_t flags2 = (flags & UNWALKABLE) | (other.flags & UNWALKABLE);
33719 17803273 ret.flags = flags1 | flags2;
33720 17803273 return ret;
33721 }
33722
33723 219038 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator &&(HeroClass::WalkflagInfo other)
33724 {
33725 219038 HeroClass::WalkflagInfo ret;
33726 219038 ret.newhopclk = newhopclk;
33727 219038 ret.newdir = newdir;
33728
1/2
✓ Branch 0 taken 219038 times.
✗ Branch 1 not taken.
219038 ret.newhopdir = (other.newhopdir >-1 ? other.newhopdir : newhopdir);
33729
33730 219038 ret.flags = flags & other.flags;
33731 219038 return ret;
33732 }
33733
33734 219038 HeroClass::WalkflagInfo HeroClass::WalkflagInfo::operator !()
33735 {
33736 219038 HeroClass::WalkflagInfo ret;
33737 219038 ret.newhopclk = newhopclk;
33738 219038 ret.newdir = newdir;
33739 219038 ret.newhopdir = newhopdir;
33740
33741 219038 ret.flags = flags ^ UNWALKABLE;
33742 219038 return ret;
33743 }
33744
33745 void HeroClass::explode(int32_t type)
33746 {
33747 static int32_t tempx, tempy;
33748 static byte herotilebuf[256];
33749 int32_t ltile=0;
33750 int32_t lflip=0;
33751 unpack_tile(newtilebuf, tile, flip, true);
33752 memcpy(herotilebuf, unpackbuf, 256);
33753 tempx=Hero.getX();
33754 tempy=Hero.getY();
33755 for(int32_t i=0; i<16; ++i)
33756 {
33757 for(int32_t j=0; j<16; ++j)
33758 {
33759 if(herotilebuf[i*16+j])
33760 {
33761 if(type==0) // Twilight
33762 {
33763 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 6, 0, 0, (zc_oldrand()%8)+i*4));
33764 int32_t k=particles.Count()-1;
33765 particle *p = (particles.at(k));
33766 p->step=3;
33767 }
33768 else if(type ==1) // Sands of Hours
33769 {
33770 particles.add(new pTwilight(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 6, 1, 2, (zc_oldrand()%16)+i*2));
33771 int32_t k=particles.Count()-1;
33772 particle *p = (particles.at(k));
33773 p->step=4;
33774
33775 if(zc_oldrand()%10 < 2)
33776 {
33777 p->color=1;
33778 p->cset=0;
33779 }
33780 }
33781 else
33782 {
33783 particles.add(new pDivineEscapeDust(Hero.getX()+j, Hero.getY()-Hero.getZ()+i, 6, 6, herotilebuf[i*16+j], zc_oldrand()%96));
33784
33785 int32_t k=particles.Count()-1;
33786 particle *p = (particles.at(k));
33787 p->angular=true;
33788 p->angle=zc_oldrand();
33789 p->step=(((double)j)/8);
33790 p->yofs=Hero.getYOfs();
33791 }
33792 }
33793 }
33794 }
33795 }
33796
33797 2224 void HeroClass::SetSwim()
33798 {
33799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2224 times.
2224 if (CanSideSwim())
33800 {
33801 if (action != sideswimattacking && action != attacking) {action=sideswimming; FFCore.setHeroAction(sideswimming);}
33802 else {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
33803 if (get_qr(qr_SIDESWIMDIR) && spins <= 0 && dir != left && dir != right) dir = sideswimdir;
33804 }
33805 2224 else {action=swimming; FFCore.setHeroAction(swimming);}
33806 2224 }
33807
33808 123544 void HeroClass::SetAttack()
33809 {
33810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123544 times.
123544 if (IsSideSwim()) {action=sideswimattacking; FFCore.setHeroAction(sideswimattacking);}
33811 123544 else {action=attacking; FFCore.setHeroAction(attacking);}
33812 123544 }
33813
33814 136176526 bool HeroClass::IsSideSwim()
33815 {
33816
6/12
✓ Branch 0 taken 136176526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136176526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136176526 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 136176526 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 136176526 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 136176526 times.
136176526 return (action==sideswimming || action==sideswimhit || action == sideswimattacking || action == sidewaterhold1 || action == sidewaterhold2 || action == sideswimcasting || action == sideswimfreeze);
33817 }
33818
33819 2782653 bool HeroClass::CanSideSwim()
33820 {
33821
1/2
✓ Branch 0 taken 2782653 times.
✗ Branch 1 not taken.
2782653 return (isSideViewHero() && get_qr(qr_SIDESWIM));
33822 }
33823
33824 12961234 int32_t HeroClass::getTileModifier()
33825 {
33826 12961234 return item_tile_mod() + bunny_tile_mod();
33827 }
33828 void HeroClass::setImmortal(int32_t nimmortal)
33829 {
33830 immortal = nimmortal;
33831 }
33832 void HeroClass::kill(bool bypassFairy)
33833 {
33834 dying_flags = DYING_FORCED | (bypassFairy ? DYING_NOREV : 0);
33835 }
33836 103482335 bool HeroClass::sideview_mode() const
33837 {
33838
3/4
✓ Branch 0 taken 2306787 times.
✓ Branch 1 taken 101175548 times.
✓ Branch 2 taken 2306787 times.
✗ Branch 3 not taken.
103482335 return isSideViewHero() && (moveflags & move_obeys_grav) && !toogam;
33839 }
33840 18082 bool HeroClass::is_unpushable() const
33841 {
33842 18082 return toogam;
33843 }
33844
33845 412 HeroClass Hero;
33846